Re: [PATCH libnetfilter_queue] src: Make sure pktb_alloc() works for IPv6 over AF_BRIDGE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 14, 2019 at 12:16:17AM +0100, Pablo Neira Ayuso wrote:
> On Thu, Nov 14, 2019 at 10:05:32AM +1100, Duncan Roe wrote:
> > 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.
> >
> > Signed-off-by: Duncan Roe <duncan_roe@xxxxxxxxxxxxxxx>
> > ---
> >  src/extra/pktbuff.c | 27 ++++++++++++++-------------
> >  1 file changed, 14 insertions(+), 13 deletions(-)
> >
> > diff --git a/src/extra/pktbuff.c b/src/extra/pktbuff.c
> > index c52b674..c99a872 100644
> > --- a/src/extra/pktbuff.c
> > +++ b/src/extra/pktbuff.c
> > @@ -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;
>
> 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;"
>
>   	case AF_BRIDGE: {
> 		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;
> >  }
> > --
> > 2.14.5
> >



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux