Commit 5d21d0a
net: generalize calculation of skb extensions length
Remove the necessity to modify skb_ext_total_length() when new extension
types are added.
Also reduces the line count a bit.
With optimizations enabled the function is folded down to the same
constant value as before during compilation.
This has been validated on x86 with GCC 6.5.0 and 13.2.1.
Also a similar construct has been validated on godbolt.org with GCC 5.1.
In any case the compiler has to be able to evaluate the construct at
compile-time for the BUILD_BUG_ON() in skb_extensions_init().
Even if not evaluated at compile-time this function would only ever
be executed once at run-time, so the overhead would be very minuscule.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230823-skb_ext-simplify-v2-1-66e26cd66860@weissschuh.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>1 parent 57ce642 commit 5d21d0a
1 file changed
+7
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4785 | 4785 | | |
4786 | 4786 | | |
4787 | 4787 | | |
4788 | | - | |
4789 | | - | |
4790 | | - | |
4791 | | - | |
4792 | | - | |
4793 | | - | |
4794 | | - | |
4795 | | - | |
4796 | | - | |
4797 | | - | |
4798 | | - | |
4799 | | - | |
4800 | | - | |
4801 | | - | |
4802 | | - | |
4803 | | - | |
4804 | | - | |
| 4788 | + | |
| 4789 | + | |
| 4790 | + | |
| 4791 | + | |
| 4792 | + | |
| 4793 | + | |
| 4794 | + | |
4805 | 4795 | | |
4806 | 4796 | | |
4807 | 4797 | | |
| |||
0 commit comments