Changeset 2991

Show
Ignore:
Timestamp:
11/28/07 22:32:50 (1 year ago)
Author:
mentor
Message:

Only try to remove padding in frames where a data body exists. Otherwise, aligning the data pushes some of it out of the buffer.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • madwifi/trunk/ath/if_ath.c

    r2988 r2991  
    58035803        struct ath_softc *sc = dev->priv; 
    58045804        struct ieee80211com *ic = &sc->sc_ic; 
    5805         struct ieee80211_frame *wh = (struct ieee80211_frame *) skb->data; 
    5806         unsigned int headersize = ieee80211_anyhdrsize(wh); 
    5807         int padbytes = roundup(headersize, 4) - headersize; 
    5808  
    5809         KASSERT(ic->ic_flags & IEEE80211_F_DATAPAD, 
    5810                 ("data padding not enabled?")); 
    5811  
    5812         if (padbytes > 0) { 
    5813                 /* Remove hw pad bytes */ 
    5814                 struct sk_buff *skb1 = skb_copy(skb, GFP_ATOMIC); 
    5815                 if (skb1 == NULL) 
    5816                         return; 
    5817                 memmove(skb1->data + padbytes, skb1->data, headersize); 
    5818                 skb_pull(skb1, padbytes); 
    5819                 /* We must duplicate the reference after an skb_copy! */ 
    5820                 if (SKB_CB(skb)->ni != NULL) { 
    5821                         SKB_CB(skb1)->ni = ieee80211_ref_node(SKB_CB(skb)->ni); 
    5822                 } 
    5823                 ieee80211_input_monitor(ic, skb1, bf, 0, rtsf, sc); 
    5824                 ieee80211_dev_kfree_skb(&skb1); 
    5825         } else { 
    5826                 ieee80211_input_monitor(ic, skb, bf, 0, rtsf, sc); 
    5827         } 
     5805        struct ieee80211_frame *wh = (struct ieee80211_frame *)skb->data; 
     5806        struct sk_buff *tskb = skb; 
     5807        unsigned int headersize; 
     5808        int padbytes; 
     5809   
     5810        KASSERT(ic->ic_flags & IEEE80211_F_DATAPAD, 
     5811                ("data padding not enabled?")); 
     5812   
     5813        /* Only non-control frames have bodies, and hence padding. */ 
     5814        if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=   
     5815                        IEEE80211_FC0_TYPE_CTL) { 
     5816                headersize = ieee80211_anyhdrsize(wh); 
     5817                padbytes = roundup(headersize, 4) - headersize; 
     5818                if (padbytes > 0) { 
     5819                        /* Copy skb and remove HW pad bytes */ 
     5820                        tskb = skb_copy(skb, GFP_ATOMIC); 
     5821                        if (tskb == NULL) 
     5822                                return; 
     5823                        /* Reference any node from the source skb. */ 
     5824                        if (SKB_CB(skb)->ni != NULL) 
     5825                                SKB_CB(tskb)->ni = ieee80211_ref_node(SKB_CB(skb)->ni); 
     5826                        memmove(tskb->data + padbytes, tskb->data, headersize); 
     5827                        skb_pull(tskb, padbytes); 
     5828                } 
     5829        } 
     5830         
     5831        ieee80211_input_monitor(ic, tskb, bf, 0, rtsf, sc); 
     5832        if (tskb != skb) 
     5833                ieee80211_dev_kfree_skb(&tskb); 
    58285834} 
    58295835 
     
    58655871        } 
    58665872 
    5867         wh = (struct ieee80211_frame *) skb->data; 
    5868         headersize = ieee80211_anyhdrsize(wh); 
    5869         padbytes = roundup(headersize, 4) - headersize; 
    5870         if (padbytes > 0) { 
    5871                 /* Unlike in rx_capture, we're freeing the skb at the end 
    5872                  * anyway, so we don't need to worry about using a copy */ 
    5873                 memmove(skb->data + padbytes, skb->data, headersize); 
    5874                 skb_pull(skb, padbytes); 
    5875         } 
    5876  
    5877         if (skb_headroom(skb) < extra && 
     5873        /* Only non-control frames have bodies, and hence padding. */ 
     5874        wh = (struct ieee80211_frame *)skb->data; 
     5875        if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=   
     5876                        IEEE80211_FC0_TYPE_CTL) { 
     5877                headersize = ieee80211_anyhdrsize(wh); 
     5878                padbytes = roundup(headersize, 4) - headersize; 
     5879                if (padbytes > 0) { 
     5880                        /* Unlike in rx_capture, we're freeing the skb at the  
     5881                         * end anyway, so we don't need to worry about using a  
     5882                         * copy. */ 
     5883                        memmove(skb->data + padbytes, skb->data, headersize); 
     5884                        skb_pull(skb, padbytes); 
     5885                } 
     5886        } 
     5887 
     5888        if ((skb_headroom(skb) < extra) && 
    58785889            pskb_expand_head(skb, extra, 0, GFP_ATOMIC)) { 
    58795890                printk("%s:%d %s\n", __FILE__, __LINE__, __func__); 
     
    58845895                /* Pass up tsf clock in mactime 
    58855896                 * TX descriptor contains the transmit time in TUs, 
    5886                  * (bits 25-10 of the TSF). 
    5887                  */ 
     5897                 * (bits 25-10 of the TSF). */ 
    58885898                tstamp = ts->ts_tstamp << 10; 
    58895899 
  • madwifi/trunk/net80211/ieee80211_proto.h

    r2482 r2991  
    120120        const struct ieee80211_frame *wh = data; 
    121121 
    122         if ((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) { 
     122        if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) { 
    123123                switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { 
    124124                case IEEE80211_FC0_SUBTYPE_CTS: 
    125125                case IEEE80211_FC0_SUBTYPE_ACK: 
    126126                        return sizeof(struct ieee80211_frame_ack); 
     127                        break; 
     128                default: 
     129                        return sizeof(struct ieee80211_frame_min); 
     130                        break; 
    127131                } 
    128                 return sizeof(struct ieee80211_frame_min); 
    129132        } else 
    130133                return ieee80211_hdrsize(data);