diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-04-24 22:19:20 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-05-02 13:16:28 +0200 |
commit | 7e38890c6b4fb5c03d436a0a8b9f3f31d65f75a4 (patch) | |
tree | 0211927df0be7685ba9937cd2f525c6ec4dc5726 /iptables/nft-bridge.c | |
parent | 165cafec1d2c1cef3255995d4e610c638dd8bd5b (diff) |
nft: prepare for dynamic register allocation
Store the register that has been allocated and pass it on to the next
expression. NFT_REG_1 is still used.
No functional changes are expected.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables/nft-bridge.c')
-rw-r--r-- | iptables/nft-bridge.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/iptables/nft-bridge.c b/iptables/nft-bridge.c index 888d4b6b..106bcc72 100644 --- a/iptables/nft-bridge.c +++ b/iptables/nft-bridge.c @@ -69,28 +69,30 @@ static void add_logical_iniface(struct nft_handle *h, struct nftnl_rule *r, char *iface, uint32_t op) { int iface_len; + uint8_t reg; iface_len = strlen(iface); - add_meta(h, r, NFT_META_BRI_IIFNAME); + add_meta(h, r, NFT_META_BRI_IIFNAME, ®); if (iface[iface_len - 1] == '+') - add_cmp_ptr(r, op, iface, iface_len - 1); + add_cmp_ptr(r, op, iface, iface_len - 1, reg); else - add_cmp_ptr(r, op, iface, iface_len + 1); + add_cmp_ptr(r, op, iface, iface_len + 1, reg); } static void add_logical_outiface(struct nft_handle *h, struct nftnl_rule *r, char *iface, uint32_t op) { int iface_len; + uint8_t reg; iface_len = strlen(iface); - add_meta(h, r, NFT_META_BRI_OIFNAME); + add_meta(h, r, NFT_META_BRI_OIFNAME, ®); if (iface[iface_len - 1] == '+') - add_cmp_ptr(r, op, iface, iface_len - 1); + add_cmp_ptr(r, op, iface, iface_len - 1, reg); else - add_cmp_ptr(r, op, iface, iface_len + 1); + add_cmp_ptr(r, op, iface, iface_len + 1, reg); } static int _add_action(struct nftnl_rule *r, struct iptables_command_state *cs) @@ -141,10 +143,12 @@ static int nft_bridge_add(struct nft_handle *h, } if ((fw->bitmask & EBT_NOPROTO) == 0) { + uint8_t reg; + op = nft_invflags2cmp(fw->invflags, EBT_IPROTO); add_payload(h, r, offsetof(struct ethhdr, h_proto), 2, - NFT_PAYLOAD_LL_HEADER); - add_cmp_u16(r, fw->ethproto, op); + NFT_PAYLOAD_LL_HEADER, ®); + add_cmp_u16(r, fw->ethproto, op, reg); } add_compat(r, fw->ethproto, fw->invflags & EBT_IPROTO); |