Skip to content

xshared: Review option parsing

Phil Sutter netfilter-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3xshared: Introduce xt_cmd_parse_ops::option_nameiptables/ip6tables.c iptables/iptables.c iptables/nft-arp.c +4 more+100 -660 replies
2/3xshared: Introduce xt_cmd_parse_ops::option_invertiptables/ip6tables.c iptables/iptables.c iptables/nft-arp.c +4 more+34 -240 replies
3/3xshared: Simplify generic_opt_check()iptables/xshared.c+28 -490 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [iptables PATCH 0/3] xshared: Review option parsing

Faced with the need to extend optflags, inverse_for_options and commands_v_options arrays in order to integrate ebtables-specific options, I chose to get rid of them all instead.

Patch 1 replaces opt2char() function which didn't work well since not every option has printable short-option character. The callback-based replacement returns the long-option and should make error messages more readable this way.

Patch 2 elminates the inverse_for_options array along with the loop turning a given option into its bit's position for use in the array. The switch statement in the replacing callback is much easier to maintain and extend.

Patch 3 makes use of the fact that no command has a mandatory option anymore. So every combination is either allowed or not, and a single bit may indicate that.

Phil Sutter (3):
xshared: Introduce xt_cmd_parse_ops::option_name
xshared: Introduce xt_cmd_parse_ops::option_invert
xshared: Simplify generic_opt_check()

 iptables/ip6tables.c |   2 +
 iptables/iptables.c  |   2 +
 iptables/nft-arp.c   |  32 ++++++
 iptables/nft-ipv4.c  |   2 +
 iptables/nft-ipv6.c  |   2 +
 iptables/xshared.c   | 249 ++++++++++++++++++++-----------------------
 iptables/xshared.h   |   6 ++
 7 files changed, 159 insertions(+), 136 deletions(-)
Signature · 1 line
2.41.0