* [B.A.T.M.A.N.] [PATCH v6 0/2] eth_hdr/skb_reset_mac_header changes
@ 2014-01-19 21:22 Linus Lüssing
2014-01-19 21:22 ` [B.A.T.M.A.N.] [PATCHv6 1/2] batman-adv: use vlan_/eth_hdr() instead of skb->data in interface_tx path Linus Lüssing
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Linus Lüssing @ 2014-01-19 21:22 UTC (permalink / raw)
To: b.a.t.m.a.n
In v6, a few more vlan_/eth_hdr()s were added to [PATCH 1/2] which are
also along the interface_tx path:
-----
bridge_loop_avoidance.c:
@@ -872,7 +872,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
gateway_client.c:
@@ -680,7 +680,7 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
@@ -689,7 +689,7 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
@@ -728,7 +728,7 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
send.c:
@@ -254,7 +254,7 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
soft-interface.c
@@ -180,7 +180,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
----
Cheers, Linus
^ permalink raw reply [flat|nested] 6+ messages in thread* [B.A.T.M.A.N.] [PATCHv6 1/2] batman-adv: use vlan_/eth_hdr() instead of skb->data in interface_tx path 2014-01-19 21:22 [B.A.T.M.A.N.] [PATCH v6 0/2] eth_hdr/skb_reset_mac_header changes Linus Lüssing @ 2014-01-19 21:22 ` Linus Lüssing 2014-01-27 7:38 ` Marek Lindner 2014-01-19 21:22 ` [B.A.T.M.A.N.] [PATCHv6 2/2] batman-adv: remove obsolete skb_reset_mac_header() in batadv_bla_tx() Linus Lüssing 2014-01-19 22:58 ` [B.A.T.M.A.N.] [PATCH v6 0/2] eth_hdr/skb_reset_mac_header changes Antonio Quartulli 2 siblings, 1 reply; 6+ messages in thread From: Linus Lüssing @ 2014-01-19 21:22 UTC (permalink / raw) To: b.a.t.m.a.n Our .ndo_start_xmit handler (batadv_interface_tx()) can rely on having the skb mac header pointer set correctly since the following commit present in kernels >= 3.9: "net: reset mac header in dev_start_xmit()" (6d1ccff627) Therefore we can safely use eth_hdr() and vlan_eth_hdr() instead of skb->data now, which spares us some ugly type casts. Signed-off-by: Linus Lüssing <linus.luessing@web.de> --- bridge_loop_avoidance.c | 2 +- compat.h | 11 +++++++++++ gateway_client.c | 6 +++--- send.c | 2 +- soft-interface.c | 8 ++++---- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 5c0eda4..407299a 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -872,7 +872,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, proto = ethhdr->h_proto; headlen = ETH_HLEN; if (vid & BATADV_VLAN_HAS_TAG) { - vhdr = (struct vlan_ethhdr *)ethhdr; + vhdr = vlan_eth_hdr(skb); proto = vhdr->h_vlan_encapsulated_proto; headlen += VLAN_HLEN; } diff --git a/compat.h b/compat.h index 57c9d96..9692ed2 100644 --- a/compat.h +++ b/compat.h @@ -302,6 +302,17 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) \ }\ static int __batadv_interface_set_mac_addr(x, y) +#define batadv_interface_tx(x, y) \ +__batadv_interface_tx(struct sk_buff *skb, struct net_device *soft_iface); \ +static int batadv_interface_tx(struct sk_buff *skb, \ + struct net_device *soft_iface) \ +{ \ + skb_reset_mac_header(skb); \ + return __batadv_interface_tx(skb, soft_iface); \ +} \ +static int __batadv_interface_tx(struct sk_buff *skb, \ + struct net_device *soft_iface) + #define netdev_master_upper_dev_link netdev_set_master #define netdev_upper_dev_unlink(slave, master) netdev_set_master(slave, NULL) #define netdev_master_upper_dev_get(dev) \ diff --git a/gateway_client.c b/gateway_client.c index 55cf226..ab0c97e 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -680,7 +680,7 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, if (!pskb_may_pull(skb, *header_len + ETH_HLEN)) return BATADV_DHCP_NO; - ethhdr = (struct ethhdr *)skb->data; + ethhdr = eth_hdr(skb); proto = ethhdr->h_proto; *header_len += ETH_HLEN; @@ -689,7 +689,7 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, if (!pskb_may_pull(skb, *header_len + VLAN_HLEN)) return BATADV_DHCP_NO; - vhdr = (struct vlan_ethhdr *)skb->data; + vhdr = vlan_eth_hdr(skb); proto = vhdr->h_vlan_encapsulated_proto; *header_len += VLAN_HLEN; } @@ -728,7 +728,7 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, return BATADV_DHCP_NO; /* skb->data might have been reallocated by pskb_may_pull() */ - ethhdr = (struct ethhdr *)skb->data; + ethhdr = eth_hdr(skb); if (ntohs(ethhdr->h_proto) == ETH_P_8021Q) ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN); diff --git a/send.c b/send.c index 579f5f0..3299b0e 100644 --- a/send.c +++ b/send.c @@ -254,7 +254,7 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node, unsigned short vid) { - struct ethhdr *ethhdr = (struct ethhdr *)skb->data; + struct ethhdr *ethhdr = eth_hdr(skb); struct batadv_unicast_packet *unicast_packet; int ret = NET_XMIT_DROP; diff --git a/soft-interface.c b/soft-interface.c index f82c267..c4392fc 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -176,11 +176,11 @@ static int batadv_interface_tx(struct sk_buff *skb, soft_iface->trans_start = jiffies; vid = batadv_get_vid(skb, 0); - ethhdr = (struct ethhdr *)skb->data; + ethhdr = eth_hdr(skb); switch (ntohs(ethhdr->h_proto)) { case ETH_P_8021Q: - vhdr = (struct vlan_ethhdr *)skb->data; + vhdr = vlan_eth_hdr(skb); if (vhdr->h_vlan_encapsulated_proto != ethertype) break; @@ -194,7 +194,7 @@ static int batadv_interface_tx(struct sk_buff *skb, goto dropped; /* skb->data might have been reallocated by batadv_bla_tx() */ - ethhdr = (struct ethhdr *)skb->data; + ethhdr = eth_hdr(skb); /* Register the client MAC in the transtable */ if (!is_multicast_ether_addr(ethhdr->h_source)) { @@ -230,7 +230,7 @@ static int batadv_interface_tx(struct sk_buff *skb, /* skb->data may have been modified by * batadv_gw_dhcp_recipient_get() */ - ethhdr = (struct ethhdr *)skb->data; + ethhdr = eth_hdr(skb); /* if gw_mode is on, broadcast any non-DHCP message. * All the DHCP packets are going to be sent as unicast */ -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv6 1/2] batman-adv: use vlan_/eth_hdr() instead of skb->data in interface_tx path 2014-01-19 21:22 ` [B.A.T.M.A.N.] [PATCHv6 1/2] batman-adv: use vlan_/eth_hdr() instead of skb->data in interface_tx path Linus Lüssing @ 2014-01-27 7:38 ` Marek Lindner 0 siblings, 0 replies; 6+ messages in thread From: Marek Lindner @ 2014-01-27 7:38 UTC (permalink / raw) To: b.a.t.m.a.n [-- Attachment #1: Type: text/plain, Size: 807 bytes --] On Sunday 19 January 2014 22:22:45 Linus Lüssing wrote: > Our .ndo_start_xmit handler (batadv_interface_tx()) can rely on having > the skb mac header pointer set correctly since the following commit > present in kernels >= 3.9: > > "net: reset mac header in dev_start_xmit()" (6d1ccff627) > > Therefore we can safely use eth_hdr() and vlan_eth_hdr() instead of > skb->data now, which spares us some ugly type casts. > > Signed-off-by: Linus Lüssing <linus.luessing@web.de> > --- > bridge_loop_avoidance.c | 2 +- > compat.h | 11 +++++++++++ > gateway_client.c | 6 +++--- > send.c | 2 +- > soft-interface.c | 8 ++++---- > 5 files changed, 20 insertions(+), 9 deletions(-) Applied in revision f9170f2. Thanks, Marek [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* [B.A.T.M.A.N.] [PATCHv6 2/2] batman-adv: remove obsolete skb_reset_mac_header() in batadv_bla_tx() 2014-01-19 21:22 [B.A.T.M.A.N.] [PATCH v6 0/2] eth_hdr/skb_reset_mac_header changes Linus Lüssing 2014-01-19 21:22 ` [B.A.T.M.A.N.] [PATCHv6 1/2] batman-adv: use vlan_/eth_hdr() instead of skb->data in interface_tx path Linus Lüssing @ 2014-01-19 21:22 ` Linus Lüssing 2014-01-27 7:39 ` Marek Lindner 2014-01-19 22:58 ` [B.A.T.M.A.N.] [PATCH v6 0/2] eth_hdr/skb_reset_mac_header changes Antonio Quartulli 2 siblings, 1 reply; 6+ messages in thread From: Linus Lüssing @ 2014-01-19 21:22 UTC (permalink / raw) To: b.a.t.m.a.n Our .ndo_start_xmit handler (batadv_interface_tx()) can rely on having the skb mac header pointer set correctly since the following commit present in kernels >= 3.9: "net: reset mac header in dev_start_xmit()" (6d1ccff627) Therefore this commit removes the according, now redundant, skb_reset_mac_header() call in batadv_bla_tx(). Signed-off-by: Linus Lüssing <linus.luessing@web.de> --- bridge_loop_avoidance.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 407299a..e69d795 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1535,9 +1535,6 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, if (!atomic_read(&bat_priv->bridge_loop_avoidance)) goto allow; - /* in VLAN case, the mac header might not be set. */ - skb_reset_mac_header(skb); - if (batadv_bla_process_claim(bat_priv, primary_if, skb)) goto handled; -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv6 2/2] batman-adv: remove obsolete skb_reset_mac_header() in batadv_bla_tx() 2014-01-19 21:22 ` [B.A.T.M.A.N.] [PATCHv6 2/2] batman-adv: remove obsolete skb_reset_mac_header() in batadv_bla_tx() Linus Lüssing @ 2014-01-27 7:39 ` Marek Lindner 0 siblings, 0 replies; 6+ messages in thread From: Marek Lindner @ 2014-01-27 7:39 UTC (permalink / raw) To: b.a.t.m.a.n [-- Attachment #1: Type: text/plain, Size: 605 bytes --] On Sunday 19 January 2014 22:22:46 Linus Lüssing wrote: > Our .ndo_start_xmit handler (batadv_interface_tx()) can rely on having > the skb mac header pointer set correctly since the following commit > present in kernels >= 3.9: > > "net: reset mac header in dev_start_xmit()" (6d1ccff627) > > Therefore this commit removes the according, now redundant, > skb_reset_mac_header() call in batadv_bla_tx(). > > Signed-off-by: Linus Lüssing <linus.luessing@web.de> > --- > bridge_loop_avoidance.c | 3 --- > 1 file changed, 3 deletions(-) Applied in revision a093442. Thanks, Marek [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH v6 0/2] eth_hdr/skb_reset_mac_header changes 2014-01-19 21:22 [B.A.T.M.A.N.] [PATCH v6 0/2] eth_hdr/skb_reset_mac_header changes Linus Lüssing 2014-01-19 21:22 ` [B.A.T.M.A.N.] [PATCHv6 1/2] batman-adv: use vlan_/eth_hdr() instead of skb->data in interface_tx path Linus Lüssing 2014-01-19 21:22 ` [B.A.T.M.A.N.] [PATCHv6 2/2] batman-adv: remove obsolete skb_reset_mac_header() in batadv_bla_tx() Linus Lüssing @ 2014-01-19 22:58 ` Antonio Quartulli 2 siblings, 0 replies; 6+ messages in thread From: Antonio Quartulli @ 2014-01-19 22:58 UTC (permalink / raw) To: The list for a Better Approach To Mobile Ad-hoc Networking [-- Attachment #1: Type: text/plain, Size: 268 bytes --] On 19/01/14 22:22, Linus Lüssing wrote: > In v6, a few more vlan_/eth_hdr()s were added to [PATCH 1/2] which are > also along the interface_tx path: > for the whole patchset: Acked-by: Antonio Quartulli <antonio@meshcoding.com> -- Antonio Quartulli [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-01-27 7:39 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-01-19 21:22 [B.A.T.M.A.N.] [PATCH v6 0/2] eth_hdr/skb_reset_mac_header changes Linus Lüssing 2014-01-19 21:22 ` [B.A.T.M.A.N.] [PATCHv6 1/2] batman-adv: use vlan_/eth_hdr() instead of skb->data in interface_tx path Linus Lüssing 2014-01-27 7:38 ` Marek Lindner 2014-01-19 21:22 ` [B.A.T.M.A.N.] [PATCHv6 2/2] batman-adv: remove obsolete skb_reset_mac_header() in batadv_bla_tx() Linus Lüssing 2014-01-27 7:39 ` Marek Lindner 2014-01-19 22:58 ` [B.A.T.M.A.N.] [PATCH v6 0/2] eth_hdr/skb_reset_mac_header changes Antonio Quartulli
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox