Page MenuHomeFreeBSD

ipfw: refactor macros around m_pullup()
ClosedPublic

Authored by glebius on Fri, Sep 4, 9:24 PM.
Tags
None
Referenced Files
F172782922: D59426.diff
Sun, Sep 20, 11:16 PM
F172737539: D59426.diff
Sun, Sep 20, 3:53 PM
Unknown Object (File)
Thu, Sep 17, 10:26 PM
Unknown Object (File)
Wed, Sep 16, 9:21 PM
Unknown Object (File)
Mon, Sep 14, 4:03 AM
Unknown Object (File)
Sat, Sep 12, 4:39 PM
Unknown Object (File)
Sat, Sep 12, 11:13 AM
Unknown Object (File)
Sat, Sep 12, 3:41 AM

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

gallatin added inline comments.
sys/netpfil/ipfw/ip_fw2.c
1548

I'd remove the word "global", as these variables are not really global; they just need to be in the current scope.

1553

I'd almost want to call this PULLUP_THRU. Eg, this is the first time i'm reading this, and I'd expect that PULLUP_TO(foo, struct tcphdr) would pull up to the *START* of the tcp header, not though the end of it.

Yes, I realize its a per-existing name, but its confusing to me..

This revision is now accepted and ready to land.Mon, Sep 7, 9:33 PM
sys/netpfil/ipfw/ip_fw2.c
1548

Right, will do.

1553

I agree with that. However, this macro has been here for a long time. I'm in favor of renaming it, but I don't want to slow down this review. If more people will say "do rename in the current review", I will do. If no, I will leave that for later. if that happens feel free to open a review that will just rename. I will vote "yes".

This revision was automatically updated to reflect the committed changes.