Skip to contentSkip to conversation

staging: p80211conv: Replace memcpy with ether_addr_copy

PATCH In review Ioana Ciornei 2 participants 3 messages Mar 18, 2015 – Mar 20, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 staging: p80211conv: Replace memcpy with ether_addr_copy

Replace memcpy() with ether_addr_copy() since addresses are __aligned(2). The 2 structures are aligned to u16:

struct p80211_hdr_a3 {
        __le16 fc;              /* 0    2 */
        u16 dur;                /* 2    2 */
        u8 a1[ETH_ALEN];        /* 4    6 */
        u8 a2[ETH_ALEN];        /* 10   6 */
        u8 a3[ETH_ALEN];        /* 16   6 */
        u16 seq;                /* 22   2 */
} __packed;

Total size: 24

struct wlan_ethhdr {
        u8 daddr[WLAN_ETHADDR_LEN];     /* 0    6 */
        u8 saddr[WLAN_ETHADDR_LEN];     /* 6    6 */
        u16 type;                       /* 12   2 */
} __packed;

Total size: 14

---

Changes in v3:
- fixed corrupted patch

 drivers/staging/wlan-ng/p80211conv.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/wlan-ng/p80211conv.c +10 -10
index bd69e8c..b3f48074 100644
@@ -178,21 +178,21 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
 
 	switch (wlandev->macmode) {
 	case WLAN_MACMODE_IBSS_STA:
-		memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a3, wlandev->bssid, ETH_ALEN);
+		ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr);
+		ether_addr_copy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr);
+		ether_addr_copy(p80211_hdr->a3.a3, wlandev->bssid);
 		break;
 	case WLAN_MACMODE_ESS_STA:
 		fc |= cpu_to_le16(WLAN_SET_FC_TODS(1));
-		memcpy(p80211_hdr->a3.a1, wlandev->bssid, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a3, &e_hdr.daddr, ETH_ALEN);
+		ether_addr_copy(p80211_hdr->a3.a1, wlandev->bssid);
+		ether_addr_copy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr);
+		ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.daddr);
 		break;
 	case WLAN_MACMODE_ESS_AP:
 		fc |= cpu_to_le16(WLAN_SET_FC_FROMDS(1));
-		memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a2, wlandev->bssid, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, ETH_ALEN);
+		ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr);
+		ether_addr_copy(p80211_hdr->a3.a2, wlandev->bssid);
+		ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.saddr);
 		break;
 	default:
 		netdev_err(wlandev->netdev,
@@ -241,7 +241,7 @@ static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
 	for (i = 0; i < wlandev->spy_number; i++) {
 
 		if (!memcmp(wlandev->spy_address[i], mac, ETH_ALEN)) {
-			memcpy(wlandev->spy_address[i], mac, ETH_ALEN);
+			ether_addr_copy(wlandev->spy_address[i], mac);
 			wlandev->spy_stat[i].level = rxmeta->signal;
 			wlandev->spy_stat[i].noise = rxmeta->noise;
 			wlandev->spy_stat[i].qual =
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 20 lines · Ioana Ciornei

Replace memcpy() with ether_addr_copy() since addresses are __aligned(2). The 2 structures are aligned to u16:

struct p80211_hdr_a3 {
        __le16 fc;              /* 0    2 */
        u16 dur;                /* 2    2 */
        u8 a1[ETH_ALEN];        /* 4    6 */
        u8 a2[ETH_ALEN];        /* 10   6 */
        u8 a3[ETH_ALEN];        /* 16   6 */
        u16 seq;                /* 22   2 */
} __packed;

Total size: 24

struct wlan_ethhdr {
        u8 daddr[WLAN_ETHADDR_LEN];     /* 0    6 */
        u8 saddr[WLAN_ETHADDR_LEN];     /* 6    6 */
        u16 type;                       /* 12   2 */
} __packed;
Quoted 7 lines

Total size: 14

---

Changes in v3:
- fixed corrupted patch

Please resend this again, after fixing the obvious build errors with it :(

ALWAYS test build your patches, to not do so annoys the people you send them to, as it breaks their workflow, and is a bit rude.

thanks,

greg k-h

#2 lore raw
Quoted 33 lines · Greg KH
Quoted 20 lines · Ioana Ciornei

Replace memcpy() with ether_addr_copy() since addresses are __aligned(2). The 2 structures are aligned to u16:

struct p80211_hdr_a3 {
        __le16 fc;              /* 0    2 */
        u16 dur;                /* 2    2 */
        u8 a1[ETH_ALEN];        /* 4    6 */
        u8 a2[ETH_ALEN];        /* 10   6 */
        u8 a3[ETH_ALEN];        /* 16   6 */
        u16 seq;                /* 22   2 */
} __packed;

Total size: 24

struct wlan_ethhdr {
        u8 daddr[WLAN_ETHADDR_LEN];     /* 0    6 */
        u8 saddr[WLAN_ETHADDR_LEN];     /* 6    6 */
        u16 type;                       /* 12   2 */
} __packed;
Quoted 7 lines

Total size: 14

---

Changes in v3:
- fixed corrupted patch

Please resend this again, after fixing the obvious build errors with it :(

Quoted 6 lines

ALWAYS test build your patches, to not do so annoys the people you send them to, as it breaks their workflow, and is a bit rude.

thanks,

greg k-h

I am very sorry. I will resend the patch.

Ioana