src: Make sure pktb_alloc() works for IPv6 over AF_BRIDGE
PATCH 1/1 src: Make sure pktb_alloc() works for IPv6 over AF_BRIDGE
At least on the local interface, the MAC header of an IPv6 packet specifies IPv6 protocol (rather than IP). This surprised me, since the first octet of the IP datagram is the IP version, but I guess it's an efficiency thing.
Without this patch, pktb_alloc() returns NULL when an IPv6 packet is encountered.
Updated:
src/extra/pktbuff.c: - Treat ETH_P_IPV6 the same as ETH_P_IP.
- Fix indenting around the affected code.
--- src/extra/pktbuff.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
src/extra/pktbuff.c +14 -13
@@ -67,21 +67,22 @@ struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra) pktb->network_header = pktb->data;break ;case AF_BRIDGE : { -struct ethhdr *ethhdr = (struct ethhdr *)pktb->data; - - pktb->mac_header = pktb->data; - -switch (ethhdr->h_proto) { -case ETH_P_IP : - pktb->network_header = pktb->data +ETH_HLEN ; +struct ethhdr *ethhdr = (struct ethhdr *)pktb->data; + + pktb->mac_header = pktb->data; + +switch (ethhdr->h_proto) { +case ETH_P_IP : +case ETH_P_IPV6 : + pktb->network_header = pktb->data +ETH_HLEN ; +break ; +default : +/* This protocol is unsupported. */ +free (pktb); +return NULL ; + }break ; -default : -/* This protocol is unsupported. */ -free (pktb); -return NULL ; } -break ; - } }return pktb; }
Signature · 1 line
2.14.5
Pablo Neira Ayuso
maintainerQuoted 23 lines · Duncan Roe
At least on the local interface, the MAC header of an IPv6 packet specifies IPv6 protocol (rather than IP). This surprised me, since the first octet of the IP datagram is the IP version, but I guess it's an efficiency thing.
Without this patch,
pktb_alloc()returns NULL when an IPv6 packet is encountered.Updated:
src/extra/pktbuff.c: - TreatETH_P_IPV6the same asETH_P_IP.
- Fix indenting around the affected code.Signed-off-by Duncan Roe <[email protected]>--- src/extra/pktbuff.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)src/extra/pktbuff.c +0
-0@@ -67,21 +67,22 @@ struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra) pktb->network_header = pktb->data;
src/extra/pktbuff.c struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra) · line 70
Quoted 10 lines
src/extra/pktbuff.c +1
-7break ;case AF_BRIDGE : { -struct ethhdr *ethhdr = (struct ethhdr *)pktb->data; - - pktb->mac_header = pktb->data; - -switch (ethhdr->h_proto) { -case ETH_P_IP : - pktb->network_header = pktb->data +ETH_HLEN ; +struct ethhdr *ethhdr = (struct ethhdr *)pktb->data;
You can save one level of indentation here, right?
case AF_BRIDGE: {
struct ethhdr *ethhdr = (struct ethhdr *)pktb->data;
...Quoted 26 lines
src/extra/pktbuff.c +12
-6+ pktb->mac_header = pktb->data; + +switch (ethhdr->h_proto) { +case ETH_P_IP : +case ETH_P_IPV6 : + pktb->network_header = pktb->data +ETH_HLEN ; +break ; +default : +/* This protocol is unsupported. */ +free (pktb); +return NULL ; + }break ; -default : -/* This protocol is unsupported. */ -free (pktb); -return NULL ; } -break ; - } }return pktb; }Signature · 1 line
2.14.5
Quoted 28 lines · Pablo Neira Ayuso
Quoted 27 lines · Duncan Roe
At least on the local interface, the MAC header of an IPv6 packet specifies IPv6 protocol (rather than IP). This surprised me, since the first octet of the IP datagram is the IP version, but I guess it's an efficiency thing.
Without this patch,
pktb_alloc()returns NULL when an IPv6 packet is encountered.Updated:
src/extra/pktbuff.c: - TreatETH_P_IPV6the same asETH_P_IP.
- Fix indenting around the affected code.Signed-off-by Duncan Roe <[email protected]>--- src/extra/pktbuff.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)src/extra/pktbuff.c +0
-2@@ -67,21 +67,22 @@ struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra) pktb->network_header = pktb->data;break ;case AF_BRIDGE : { -struct ethhdr *ethhdr = (struct ethhdr *)pktb->data; -
Quoted 8 lines
src/extra/pktbuff.c struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra) · line 70
Quoted 6 lines
src/extra/pktbuff.c +1
-5- pktb->mac_header = pktb->data; - -switch (ethhdr->h_proto) { -case ETH_P_IP : - pktb->network_header = pktb->data +ETH_HLEN ; +struct ethhdr *ethhdr = (struct ethhdr *)pktb->data;You can save one level of indentation here, right?
No, the patch introduced the new level because case AF_BRIDGE has a brace after it, unlike e.g. case ETH_P_IP.
Without this extra indentation you get two consecutive brace lines with the same indentation immediately before "return pktb;"
Quoted 31 lines
case AF_BRIDGE: { struct ethhdr *ethhdr = (struct ethhdr *)pktb->data; ...Quoted 26 lines
src/extra/pktbuff.c +12
-7+ pktb->mac_header = pktb->data; + +switch (ethhdr->h_proto) { +case ETH_P_IP : +case ETH_P_IPV6 : + pktb->network_header = pktb->data +ETH_HLEN ; +break ; +default : +/* This protocol is unsupported. */ +free (pktb); +return NULL ; + }break ; -default : -/* This protocol is unsupported. */ -free (pktb); -return NULL ; } -break ; - } }return pktb; } --2.14.5
Quoted 6 lines · Duncan Roe
At least on the local interface, the MAC header of an IPv6 packet specifies IPv6 protocol (rather than IP). This surprised me, since the first octet of the IP datagram is the IP version, but I guess it's an efficiency thing.
Without this patch,
pktb_alloc()returns NULL when an IPv6 packet is encountered.
Applied, thanks.
Quoted 4 lines
Updated:
src/extra/pktbuff.c: - TreatETH_P_IPV6the same asETH_P_IP.
- Fix indenting around the affected code.
I have left indentation as is, so this becomes a oneliner.
This double closing curly brace on the same column is bizarre indeed, but not convinced this double indentation looks better. And I like this patch became just a oneliner. Thanks.