Skip to content

Commit e45a79d

Browse files
committed
skbuff/mac80211: introduce and use skb_put_zero()
This pattern was introduced a number of times in mac80211 just now, and since it's present in a number of other places it makes sense to add a little helper for it. This just adds the helper and transforms the mac80211 code, a later patch will transform other places. Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 71ec289 commit e45a79d

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

include/linux/skbuff.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,6 +1937,15 @@ static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
19371937
return tmp;
19381938
}
19391939

1940+
static inline unsigned char *skb_put_zero(struct sk_buff *skb, unsigned int len)
1941+
{
1942+
unsigned char *tmp = skb_put(skb, len);
1943+
1944+
memset(tmp, 0, len);
1945+
1946+
return tmp;
1947+
}
1948+
19401949
unsigned char *skb_push(struct sk_buff *skb, unsigned int len);
19411950
static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len)
19421951
{

net/mac80211/mesh.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,7 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
744744
int ie_len = 2 + sizeof(struct ieee80211_channel_sw_ie) +
745745
2 + sizeof(struct ieee80211_mesh_chansw_params_ie);
746746

747-
pos = skb_put(skb, ie_len);
748-
memset(pos, 0, ie_len);
747+
pos = skb_put_zero(skb, ie_len);
749748
*pos++ = WLAN_EID_CHANNEL_SWITCH;
750749
*pos++ = 3;
751750
*pos++ = 0x0;
@@ -772,8 +771,7 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
772771
switch (csa->settings.chandef.width) {
773772
case NL80211_CHAN_WIDTH_40:
774773
ie_len = 2 + sizeof(struct ieee80211_sec_chan_offs_ie);
775-
pos = skb_put(skb, ie_len);
776-
memset(pos, 0, ie_len);
774+
pos = skb_put_zero(skb, ie_len);
777775

778776
*pos++ = WLAN_EID_SECONDARY_CHANNEL_OFFSET; /* EID */
779777
*pos++ = 1; /* len */
@@ -789,8 +787,7 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
789787
/* Channel Switch Wrapper + Wide Bandwidth CSA IE */
790788
ie_len = 2 + 2 +
791789
sizeof(struct ieee80211_wide_bw_chansw_ie);
792-
pos = skb_put(skb, ie_len);
793-
memset(pos, 0, ie_len);
790+
pos = skb_put_zero(skb, ie_len);
794791

795792
*pos++ = WLAN_EID_CHANNEL_SWITCH_WRAPPER; /* EID */
796793
*pos++ = 5; /* len */

net/mac80211/mesh_plink.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
264264
band = sband->band;
265265

266266
/* capability info */
267-
pos = skb_put(skb, 2);
268-
memset(pos, 0, 2);
267+
pos = skb_put_zero(skb, 2);
269268
if (action == WLAN_SP_MESH_PEERING_CONFIRM) {
270269
/* AID */
271270
pos = skb_put(skb, 2);

0 commit comments

Comments
 (0)