Page MenuHomeFreeBSD

ipfw: refactor macros around m_pullup()
Needs ReviewPublic

Authored by glebius on Fri, Sep 4, 9:24 PM.

Details

Summary

In the prologue, where we check if the argument is a memory or an mbuf
chain, do not set 'struct ip *ip' pointer. However, set the 'struct
ether_header *eh' pointer there and set Etherner header length in 'ehlen'.
Side effect of this refactor is that now Layer 2 hooks may send mbufs with
ETHERTYPE_VLAN frames. However, current network stack doesn't do that.

Write a new PULLUP() macro that would take type of the argument to
determine how much to pull. Unlike PULLUP_TO() this macro can take typed
pointer. This will allow to get rid of 'void *ulp' and bunch of casting
macros in the next change. Use local bool variable to see if we need to
unlock upon jump to pullup_failed. Embed pointer update into the branch
of the macro, where pointers indeed need an update.

Use new PULLUP() macro to pullup initial 'struct ip *ip' and 'struct
ip6_hdr *ip6'. This removes max_protohdr sized pullup, that previously
tried to pull more than an unmapped mbuf could yield, fixing a bug covered
by the testcase sys/netpfil/ipfw/unmapped.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76538
Build 73421: arc lint + arc unit

Event Timeline

Otherwise I like this.

sys/netpfil/ipfw/ip_fw2.c
1556

Is _x not really _end or _maxlen or something like that? Would read better?

1813

This is a mechanical change? PULLUP_TO?

sys/netpfil/ipfw/ip_fw2.c
1556

Maybe _max?

1813

I have next change that changes this line to PULLUP(sctp).

sys/netpfil/ipfw/ip_fw2.c
1556

Seem good! Thanks!

1813

ACK