Re: [PATCH net-next] net: ptp: get rid of IPV4_HLEN() and OFF_IHL macros

From: Richard Cochran
Date: Fri Oct 16 2020 - 08:53:06 EST


On Fri, Oct 16, 2020 at 09:04:38AM +0200, Christian Eggers wrote:
> IPV4_HLEN() is only used for PTP. Is there any way to use "normal"
> infrastructure as in the rest of the network stack?

You answered your own question...

> It looks like PTP code
> typically has to look into multiple network layers (mac, network, transport)
> at places these layers may not be processed yet (at least in RX direction).

here!

(The pointers in the skb are moved around as the skb flows through the stack.)

The original, per-driver, un-refactored callers of that macro (at
least the ones written by me) used the macro carefully. Also, I think
the recent re-factoring that Kurt implemented preserves the correct
usage of the macro. Any new users must, of course, use it carefully
while parsing the bytes of a frame.

I agree that the macro is perhaps not the best possible solution, but
it is not the worst either.

Thanks,
Richard