Commit 613dbd95 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

netfilter: x_tables: move hook state into xt_action_param structure

Place pointer to hook state in xt_action_param structure instead of
copying the fields that we need. After this change xt_action_param fits
into one cacheline.

This patch also adds a set of new wrapper functions to fetch relevant
hook state structure fields.
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 06fd3a39
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/static_key.h> #include <linux/static_key.h>
#include <linux/netfilter.h>
#include <uapi/linux/netfilter/x_tables.h> #include <uapi/linux/netfilter/x_tables.h>
/* Test a struct->invflags and a boolean for inequality */ /* Test a struct->invflags and a boolean for inequality */
...@@ -17,14 +18,9 @@ ...@@ -17,14 +18,9 @@
* @target: the target extension * @target: the target extension
* @matchinfo: per-match data * @matchinfo: per-match data
* @targetinfo: per-target data * @targetinfo: per-target data
* @net network namespace through which the action was invoked * @state: pointer to hook state this packet came from
* @in: input netdevice
* @out: output netdevice
* @fragoff: packet is a fragment, this is the data offset * @fragoff: packet is a fragment, this is the data offset
* @thoff: position of transport header relative to skb->data * @thoff: position of transport header relative to skb->data
* @hook: hook number given packet came from
* @family: Actual NFPROTO_* through which the function is invoked
* (helpful when match->family == NFPROTO_UNSPEC)
* *
* Fields written to by extensions: * Fields written to by extensions:
* *
...@@ -38,15 +34,47 @@ struct xt_action_param { ...@@ -38,15 +34,47 @@ struct xt_action_param {
union { union {
const void *matchinfo, *targinfo; const void *matchinfo, *targinfo;
}; };
struct net *net; const struct nf_hook_state *state;
const struct net_device *in, *out;
int fragoff; int fragoff;
unsigned int thoff; unsigned int thoff;
unsigned int hooknum;
u_int8_t family;
bool hotdrop; bool hotdrop;
}; };
static inline struct net *xt_net(const struct xt_action_param *par)
{
return par->state->net;
}
static inline struct net_device *xt_in(const struct xt_action_param *par)
{
return par->state->in;
}
static inline const char *xt_inname(const struct xt_action_param *par)
{
return par->state->in->name;
}
static inline struct net_device *xt_out(const struct xt_action_param *par)
{
return par->state->out;
}
static inline const char *xt_outname(const struct xt_action_param *par)
{
return par->state->out->name;
}
static inline unsigned int xt_hooknum(const struct xt_action_param *par)
{
return par->state->hook;
}
static inline u_int8_t xt_family(const struct xt_action_param *par)
{
return par->state->pf;
}
/** /**
* struct xt_mtchk_param - parameters for match extensions' * struct xt_mtchk_param - parameters for match extensions'
* checkentry functions * checkentry functions
......
...@@ -30,11 +30,12 @@ static inline void nft_set_pktinfo(struct nft_pktinfo *pkt, ...@@ -30,11 +30,12 @@ static inline void nft_set_pktinfo(struct nft_pktinfo *pkt,
const struct nf_hook_state *state) const struct nf_hook_state *state)
{ {
pkt->skb = skb; pkt->skb = skb;
pkt->net = pkt->xt.net = state->net; pkt->net = state->net;
pkt->in = pkt->xt.in = state->in; pkt->in = state->in;
pkt->out = pkt->xt.out = state->out; pkt->out = state->out;
pkt->hook = pkt->xt.hooknum = state->hook; pkt->hook = state->hook;
pkt->pf = pkt->xt.family = state->pf; pkt->pf = state->pf;
pkt->xt.state = state;
} }
static inline void nft_set_pktinfo_proto_unspec(struct nft_pktinfo *pkt, static inline void nft_set_pktinfo_proto_unspec(struct nft_pktinfo *pkt,
......
...@@ -51,7 +51,8 @@ ebt_arpreply_tg(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -51,7 +51,8 @@ ebt_arpreply_tg(struct sk_buff *skb, const struct xt_action_param *par)
if (diptr == NULL) if (diptr == NULL)
return EBT_DROP; return EBT_DROP;
arp_send(ARPOP_REPLY, ETH_P_ARP, *siptr, (struct net_device *)par->in, arp_send(ARPOP_REPLY, ETH_P_ARP, *siptr,
(struct net_device *)xt_in(par),
*diptr, shp, info->mac, shp); *diptr, shp, info->mac, shp);
return info->target; return info->target;
......
...@@ -179,7 +179,7 @@ ebt_log_tg(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -179,7 +179,7 @@ ebt_log_tg(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct ebt_log_info *info = par->targinfo; const struct ebt_log_info *info = par->targinfo;
struct nf_loginfo li; struct nf_loginfo li;
struct net *net = par->net; struct net *net = xt_net(par);
li.type = NF_LOG_TYPE_LOG; li.type = NF_LOG_TYPE_LOG;
li.u.log.level = info->loglevel; li.u.log.level = info->loglevel;
...@@ -190,11 +190,12 @@ ebt_log_tg(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -190,11 +190,12 @@ ebt_log_tg(struct sk_buff *skb, const struct xt_action_param *par)
* nf_log_packet() with NFT_LOG_TYPE_LOG here. --Pablo * nf_log_packet() with NFT_LOG_TYPE_LOG here. --Pablo
*/ */
if (info->bitmask & EBT_LOG_NFLOG) if (info->bitmask & EBT_LOG_NFLOG)
nf_log_packet(net, NFPROTO_BRIDGE, par->hooknum, skb, nf_log_packet(net, NFPROTO_BRIDGE, xt_hooknum(par), skb,
par->in, par->out, &li, "%s", info->prefix); xt_in(par), xt_out(par), &li, "%s",
info->prefix);
else else
ebt_log_packet(net, NFPROTO_BRIDGE, par->hooknum, skb, par->in, ebt_log_packet(net, NFPROTO_BRIDGE, xt_hooknum(par), skb,
par->out, &li, info->prefix); xt_in(par), xt_out(par), &li, info->prefix);
return EBT_CONTINUE; return EBT_CONTINUE;
} }
......
...@@ -23,16 +23,16 @@ static unsigned int ...@@ -23,16 +23,16 @@ static unsigned int
ebt_nflog_tg(struct sk_buff *skb, const struct xt_action_param *par) ebt_nflog_tg(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct ebt_nflog_info *info = par->targinfo; const struct ebt_nflog_info *info = par->targinfo;
struct net *net = xt_net(par);
struct nf_loginfo li; struct nf_loginfo li;
struct net *net = par->net;
li.type = NF_LOG_TYPE_ULOG; li.type = NF_LOG_TYPE_ULOG;
li.u.ulog.copy_len = info->len; li.u.ulog.copy_len = info->len;
li.u.ulog.group = info->group; li.u.ulog.group = info->group;
li.u.ulog.qthreshold = info->threshold; li.u.ulog.qthreshold = info->threshold;
nf_log_packet(net, PF_BRIDGE, par->hooknum, skb, par->in, nf_log_packet(net, PF_BRIDGE, xt_hooknum(par), skb, xt_in(par),
par->out, &li, "%s", info->prefix); xt_out(par), &li, "%s", info->prefix);
return EBT_CONTINUE; return EBT_CONTINUE;
} }
......
...@@ -23,12 +23,12 @@ ebt_redirect_tg(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -23,12 +23,12 @@ ebt_redirect_tg(struct sk_buff *skb, const struct xt_action_param *par)
if (!skb_make_writable(skb, 0)) if (!skb_make_writable(skb, 0))
return EBT_DROP; return EBT_DROP;
if (par->hooknum != NF_BR_BROUTING) if (xt_hooknum(par) != NF_BR_BROUTING)
/* rcu_read_lock()ed by nf_hook_thresh */ /* rcu_read_lock()ed by nf_hook_thresh */
ether_addr_copy(eth_hdr(skb)->h_dest, ether_addr_copy(eth_hdr(skb)->h_dest,
br_port_get_rcu(par->in)->br->dev->dev_addr); br_port_get_rcu(xt_in(par))->br->dev->dev_addr);
else else
ether_addr_copy(eth_hdr(skb)->h_dest, par->in->dev_addr); ether_addr_copy(eth_hdr(skb)->h_dest, xt_in(par)->dev_addr);
skb->pkt_type = PACKET_HOST; skb->pkt_type = PACKET_HOST;
return info->target; return info->target;
} }
......
...@@ -194,12 +194,8 @@ unsigned int ebt_do_table(struct sk_buff *skb, ...@@ -194,12 +194,8 @@ unsigned int ebt_do_table(struct sk_buff *skb,
const struct ebt_table_info *private; const struct ebt_table_info *private;
struct xt_action_param acpar; struct xt_action_param acpar;
acpar.family = NFPROTO_BRIDGE; acpar.state = state;
acpar.net = state->net;
acpar.in = state->in;
acpar.out = state->out;
acpar.hotdrop = false; acpar.hotdrop = false;
acpar.hooknum = hook;
read_lock_bh(&table->lock); read_lock_bh(&table->lock);
private = table->private; private = table->private;
......
...@@ -217,11 +217,7 @@ unsigned int arpt_do_table(struct sk_buff *skb, ...@@ -217,11 +217,7 @@ unsigned int arpt_do_table(struct sk_buff *skb,
*/ */
e = get_entry(table_base, private->hook_entry[hook]); e = get_entry(table_base, private->hook_entry[hook]);
acpar.net = state->net; acpar.state = state;
acpar.in = state->in;
acpar.out = state->out;
acpar.hooknum = hook;
acpar.family = NFPROTO_ARP;
acpar.hotdrop = false; acpar.hotdrop = false;
arp = arp_hdr(skb); arp = arp_hdr(skb);
......
...@@ -261,11 +261,7 @@ ipt_do_table(struct sk_buff *skb, ...@@ -261,11 +261,7 @@ ipt_do_table(struct sk_buff *skb,
acpar.fragoff = ntohs(ip->frag_off) & IP_OFFSET; acpar.fragoff = ntohs(ip->frag_off) & IP_OFFSET;
acpar.thoff = ip_hdrlen(skb); acpar.thoff = ip_hdrlen(skb);
acpar.hotdrop = false; acpar.hotdrop = false;
acpar.net = state->net; acpar.state = state;
acpar.in = state->in;
acpar.out = state->out;
acpar.family = NFPROTO_IPV4;
acpar.hooknum = hook;
IP_NF_ASSERT(table->valid_hooks & (1 << hook)); IP_NF_ASSERT(table->valid_hooks & (1 << hook));
local_bh_disable(); local_bh_disable();
......
...@@ -55,7 +55,8 @@ masquerade_tg(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -55,7 +55,8 @@ masquerade_tg(struct sk_buff *skb, const struct xt_action_param *par)
range.min_proto = mr->range[0].min; range.min_proto = mr->range[0].min;
range.max_proto = mr->range[0].max; range.max_proto = mr->range[0].max;
return nf_nat_masquerade_ipv4(skb, par->hooknum, &range, par->out); return nf_nat_masquerade_ipv4(skb, xt_hooknum(par), &range,
xt_out(par));
} }
static struct xt_target masquerade_tg_reg __read_mostly = { static struct xt_target masquerade_tg_reg __read_mostly = {
......
...@@ -34,7 +34,7 @@ static unsigned int ...@@ -34,7 +34,7 @@ static unsigned int
reject_tg(struct sk_buff *skb, const struct xt_action_param *par) reject_tg(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct ipt_reject_info *reject = par->targinfo; const struct ipt_reject_info *reject = par->targinfo;
int hook = par->hooknum; int hook = xt_hooknum(par);
switch (reject->with) { switch (reject->with) {
case IPT_ICMP_NET_UNREACHABLE: case IPT_ICMP_NET_UNREACHABLE:
...@@ -59,7 +59,7 @@ reject_tg(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -59,7 +59,7 @@ reject_tg(struct sk_buff *skb, const struct xt_action_param *par)
nf_send_unreach(skb, ICMP_PKT_FILTERED, hook); nf_send_unreach(skb, ICMP_PKT_FILTERED, hook);
break; break;
case IPT_TCP_RESET: case IPT_TCP_RESET:
nf_send_reset(par->net, skb, hook); nf_send_reset(xt_net(par), skb, hook);
case IPT_ICMP_ECHOREPLY: case IPT_ICMP_ECHOREPLY:
/* Doesn't happen. */ /* Doesn't happen. */
break; break;
......
...@@ -263,12 +263,12 @@ static unsigned int ...@@ -263,12 +263,12 @@ static unsigned int
synproxy_tg4(struct sk_buff *skb, const struct xt_action_param *par) synproxy_tg4(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct xt_synproxy_info *info = par->targinfo; const struct xt_synproxy_info *info = par->targinfo;
struct net *net = par->net; struct net *net = xt_net(par);
struct synproxy_net *snet = synproxy_pernet(net); struct synproxy_net *snet = synproxy_pernet(net);
struct synproxy_options opts = {}; struct synproxy_options opts = {};
struct tcphdr *th, _th; struct tcphdr *th, _th;
if (nf_ip_checksum(skb, par->hooknum, par->thoff, IPPROTO_TCP)) if (nf_ip_checksum(skb, xt_hooknum(par), par->thoff, IPPROTO_TCP))
return NF_DROP; return NF_DROP;
th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th); th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th);
......
...@@ -95,7 +95,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -95,7 +95,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
flow.flowi4_tos = RT_TOS(iph->tos); flow.flowi4_tos = RT_TOS(iph->tos);
flow.flowi4_scope = RT_SCOPE_UNIVERSE; flow.flowi4_scope = RT_SCOPE_UNIVERSE;
return rpfilter_lookup_reverse(par->net, &flow, par->in, info->flags) ^ invert; return rpfilter_lookup_reverse(xt_net(par), &flow, xt_in(par), info->flags) ^ invert;
} }
static int rpfilter_check(const struct xt_mtchk_param *par) static int rpfilter_check(const struct xt_mtchk_param *par)
......
...@@ -291,11 +291,7 @@ ip6t_do_table(struct sk_buff *skb, ...@@ -291,11 +291,7 @@ ip6t_do_table(struct sk_buff *skb,
* rule is also a fragment-specific rule, non-fragments won't * rule is also a fragment-specific rule, non-fragments won't
* match it. */ * match it. */
acpar.hotdrop = false; acpar.hotdrop = false;
acpar.net = state->net; acpar.state = state;
acpar.in = state->in;
acpar.out = state->out;
acpar.family = NFPROTO_IPV6;
acpar.hooknum = hook;
IP_NF_ASSERT(table->valid_hooks & (1 << hook)); IP_NF_ASSERT(table->valid_hooks & (1 << hook));
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
static unsigned int static unsigned int
masquerade_tg6(struct sk_buff *skb, const struct xt_action_param *par) masquerade_tg6(struct sk_buff *skb, const struct xt_action_param *par)
{ {
return nf_nat_masquerade_ipv6(skb, par->targinfo, par->out); return nf_nat_masquerade_ipv6(skb, par->targinfo, xt_out(par));
} }
static int masquerade_tg6_checkentry(const struct xt_tgchk_param *par) static int masquerade_tg6_checkentry(const struct xt_tgchk_param *par)
......
...@@ -39,35 +39,40 @@ static unsigned int ...@@ -39,35 +39,40 @@ static unsigned int
reject_tg6(struct sk_buff *skb, const struct xt_action_param *par) reject_tg6(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct ip6t_reject_info *reject = par->targinfo; const struct ip6t_reject_info *reject = par->targinfo;
struct net *net = par->net; struct net *net = xt_net(par);
switch (reject->with) { switch (reject->with) {
case IP6T_ICMP6_NO_ROUTE: case IP6T_ICMP6_NO_ROUTE:
nf_send_unreach6(net, skb, ICMPV6_NOROUTE, par->hooknum); nf_send_unreach6(net, skb, ICMPV6_NOROUTE, xt_hooknum(par));
break; break;
case IP6T_ICMP6_ADM_PROHIBITED: case IP6T_ICMP6_ADM_PROHIBITED:
nf_send_unreach6(net, skb, ICMPV6_ADM_PROHIBITED, par->hooknum); nf_send_unreach6(net, skb, ICMPV6_ADM_PROHIBITED,
xt_hooknum(par));
break; break;
case IP6T_ICMP6_NOT_NEIGHBOUR: case IP6T_ICMP6_NOT_NEIGHBOUR:
nf_send_unreach6(net, skb, ICMPV6_NOT_NEIGHBOUR, par->hooknum); nf_send_unreach6(net, skb, ICMPV6_NOT_NEIGHBOUR,
xt_hooknum(par));
break; break;
case IP6T_ICMP6_ADDR_UNREACH: case IP6T_ICMP6_ADDR_UNREACH:
nf_send_unreach6(net, skb, ICMPV6_ADDR_UNREACH, par->hooknum); nf_send_unreach6(net, skb, ICMPV6_ADDR_UNREACH,
xt_hooknum(par));
break; break;
case IP6T_ICMP6_PORT_UNREACH: case IP6T_ICMP6_PORT_UNREACH:
nf_send_unreach6(net, skb, ICMPV6_PORT_UNREACH, par->hooknum); nf_send_unreach6(net, skb, ICMPV6_PORT_UNREACH,
xt_hooknum(par));
break; break;
case IP6T_ICMP6_ECHOREPLY: case IP6T_ICMP6_ECHOREPLY:
/* Do nothing */ /* Do nothing */
break; break;
case IP6T_TCP_RESET: case IP6T_TCP_RESET:
nf_send_reset6(net, skb, par->hooknum); nf_send_reset6(net, skb, xt_hooknum(par));
break; break;
case IP6T_ICMP6_POLICY_FAIL: case IP6T_ICMP6_POLICY_FAIL:
nf_send_unreach6(net, skb, ICMPV6_POLICY_FAIL, par->hooknum); nf_send_unreach6(net, skb, ICMPV6_POLICY_FAIL, xt_hooknum(par));
break; break;
case IP6T_ICMP6_REJECT_ROUTE: case IP6T_ICMP6_REJECT_ROUTE:
nf_send_unreach6(net, skb, ICMPV6_REJECT_ROUTE, par->hooknum); nf_send_unreach6(net, skb, ICMPV6_REJECT_ROUTE,
xt_hooknum(par));
break; break;
} }
......
...@@ -277,12 +277,12 @@ static unsigned int ...@@ -277,12 +277,12 @@ static unsigned int
synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par) synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct xt_synproxy_info *info = par->targinfo; const struct xt_synproxy_info *info = par->targinfo;
struct net *net = par->net; struct net *net = xt_net(par);
struct synproxy_net *snet = synproxy_pernet(net); struct synproxy_net *snet = synproxy_pernet(net);
struct synproxy_options opts = {}; struct synproxy_options opts = {};
struct tcphdr *th, _th; struct tcphdr *th, _th;
if (nf_ip6_checksum(skb, par->hooknum, par->thoff, IPPROTO_TCP)) if (nf_ip6_checksum(skb, xt_hooknum(par), par->thoff, IPPROTO_TCP))
return NF_DROP; return NF_DROP;
th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th); th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th);
......
...@@ -93,7 +93,8 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -93,7 +93,8 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
if (unlikely(saddrtype == IPV6_ADDR_ANY)) if (unlikely(saddrtype == IPV6_ADDR_ANY))
return true ^ invert; /* not routable: forward path will drop it */ return true ^ invert; /* not routable: forward path will drop it */
return rpfilter_lookup_reverse6(par->net, skb, par->in, info->flags) ^ invert; return rpfilter_lookup_reverse6(xt_net(par), skb, xt_in(par),
info->flags) ^ invert;
} }
static int rpfilter_check(const struct xt_mtchk_param *par) static int rpfilter_check(const struct xt_mtchk_param *par)
......
...@@ -541,7 +541,7 @@ int ...@@ -541,7 +541,7 @@ int
ip_set_test(ip_set_id_t index, const struct sk_buff *skb, ip_set_test(ip_set_id_t index, const struct sk_buff *skb,
const struct xt_action_param *par, struct ip_set_adt_opt *opt) const struct xt_action_param *par, struct ip_set_adt_opt *opt)
{ {
struct ip_set *set = ip_set_rcu_get(par->net, index); struct ip_set *set = ip_set_rcu_get(xt_net(par), index);
int ret = 0; int ret = 0;
BUG_ON(!set); BUG_ON(!set);
...@@ -579,7 +579,7 @@ int ...@@ -579,7 +579,7 @@ int
ip_set_add(ip_set_id_t index, const struct sk_buff *skb, ip_set_add(ip_set_id_t index, const struct sk_buff *skb,
const struct xt_action_param *par, struct ip_set_adt_opt *opt) const struct xt_action_param *par, struct ip_set_adt_opt *opt)
{ {
struct ip_set *set = ip_set_rcu_get(par->net, index); struct ip_set *set = ip_set_rcu_get(xt_net(par), index);
int ret; int ret;
BUG_ON(!set); BUG_ON(!set);
...@@ -601,7 +601,7 @@ int ...@@ -601,7 +601,7 @@ int
ip_set_del(ip_set_id_t index, const struct sk_buff *skb, ip_set_del(ip_set_id_t index, const struct sk_buff *skb,
const struct xt_action_param *par, struct ip_set_adt_opt *opt) const struct xt_action_param *par, struct ip_set_adt_opt *opt)
{ {
struct ip_set *set = ip_set_rcu_get(par->net, index); struct ip_set *set = ip_set_rcu_get(xt_net(par), index);
int ret = 0; int ret = 0;
BUG_ON(!set); BUG_ON(!set);
......
...@@ -170,7 +170,7 @@ hash_netiface4_kadt(struct ip_set *set, const struct sk_buff *skb, ...@@ -170,7 +170,7 @@ hash_netiface4_kadt(struct ip_set *set, const struct sk_buff *skb,
ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip); ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip);
e.ip &= ip_set_netmask(e.cidr); e.ip &= ip_set_netmask(e.cidr);
#define IFACE(dir) (par->dir ? par->dir->name : "") #define IFACE(dir) (par->state->dir ? par->state->dir->name : "")
#define SRCDIR (opt->flags & IPSET_DIM_TWO_SRC) #define SRCDIR (opt->flags & IPSET_DIM_TWO_SRC)
if (opt->cmdflags & IPSET_FLAG_PHYSDEV) { if (opt->cmdflags & IPSET_FLAG_PHYSDEV) {
......
...@@ -132,9 +132,9 @@ audit_tg(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -132,9 +132,9 @@ audit_tg(struct sk_buff *skb, const struct xt_action_param *par)
goto errout; goto errout;
audit_log_format(ab, "action=%hhu hook=%u len=%u inif=%s outif=%s", audit_log_format(ab, "action=%hhu hook=%u len=%u inif=%s outif=%s",
info->type, par->hooknum, skb->len, info->type, xt_hooknum(par), skb->len,
par->in ? par->in->name : "?", xt_in(par) ? xt_inname(par) : "?",
par->out ? par->out->name : "?"); xt_out(par) ? xt_outname(par) : "?");
if (skb->mark) if (skb->mark)
audit_log_format(ab, " mark=%#x", skb->mark); audit_log_format(ab, " mark=%#x", skb->mark);
...@@ -144,7 +144,7 @@ audit_tg(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -144,7 +144,7 @@ audit_tg(struct sk_buff *skb, const struct xt_action_param *par)
eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest, eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
ntohs(eth_hdr(skb)->h_proto)); ntohs(eth_hdr(skb)->h_proto));
if (par->family == NFPROTO_BRIDGE) { if (xt_family(par) == NFPROTO_BRIDGE) {
switch (eth_hdr(skb)->h_proto) { switch (eth_hdr(skb)->h_proto) {
case htons(ETH_P_IP): case htons(ETH_P_IP):
audit_ip4(ab, skb); audit_ip4(ab, skb);
...@@ -157,7 +157,7 @@ audit_tg(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -157,7 +157,7 @@ audit_tg(struct sk_buff *skb, const struct xt_action_param *par)
} }
} }
switch (par->family) { switch (xt_family(par)) {
case NFPROTO_IPV4: case NFPROTO_IPV4:
audit_ip4(ab, skb); audit_ip4(ab, skb);
break; break;
......
...@@ -32,15 +32,15 @@ static unsigned int ...@@ -32,15 +32,15 @@ static unsigned int
log_tg(struct sk_buff *skb, const struct xt_action_param *par) log_tg(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct xt_log_info *loginfo = par->targinfo; const struct xt_log_info *loginfo = par->targinfo;
struct net *net = xt_net(par);
struct nf_loginfo li; struct nf_loginfo li;
struct net *net = par->net;
li.type = NF_LOG_TYPE_LOG; li.type = NF_LOG_TYPE_LOG;
li.u.log.level = loginfo->level; li.u.log.level = loginfo->level;
li.u.log.logflags = loginfo->logflags; li.u.log.logflags = loginfo->logflags;
nf_log_packet(net, par->family, par->hooknum, skb, par->in, par->out, nf_log_packet(net, xt_family(par), xt_hooknum(par), skb, xt_in(par),
&li, "%s", loginfo->prefix); xt_out(par), &li, "%s", loginfo->prefix);
return XT_CONTINUE; return XT_CONTINUE;
} }
......
...@@ -33,8 +33,8 @@ netmap_tg6(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -33,8 +33,8 @@ netmap_tg6(struct sk_buff *skb, const struct xt_action_param *par)
netmask.ip6[i] = ~(range->min_addr.ip6[i] ^ netmask.ip6[i] = ~(range->min_addr.ip6[i] ^
range->max_addr.ip6[i]); range->max_addr.ip6[i]);
if (par->hooknum == NF_INET_PRE_ROUTING || if (xt_hooknum(par) == NF_INET_PRE_ROUTING ||
par->hooknum == NF_INET_LOCAL_OUT) xt_hooknum(par) == NF_INET_LOCAL_OUT)
new_addr.in6 = ipv6_hdr(skb)->daddr; new_addr.in6 = ipv6_hdr(skb)->daddr;
else else
new_addr.in6 = ipv6_hdr(skb)->saddr; new_addr.in6 = ipv6_hdr(skb)->saddr;
...@@ -51,7 +51,7 @@ netmap_tg6(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -51,7 +51,7 @@ netmap_tg6(struct sk_buff *skb, const struct xt_action_param *par)
newrange.min_proto = range->min_proto; newrange.min_proto = range->min_proto;
newrange.max_proto = range->max_proto; newrange.max_proto = range->max_proto;
return nf_nat_setup_info(ct, &newrange, HOOK2MANIP(par->hooknum)); return nf_nat_setup_info(ct, &newrange, HOOK2MANIP(xt_hooknum(par)));
} }
static int netmap_tg6_checkentry(const struct xt_tgchk_param *par) static int netmap_tg6_checkentry(const struct xt_tgchk_param *par)
...@@ -72,16 +72,16 @@ netmap_tg4(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -72,16 +72,16 @@ netmap_tg4(struct sk_buff *skb, const struct xt_action_param *par)
const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo;
struct nf_nat_range newrange; struct nf_nat_range newrange;
NF_CT_ASSERT(par->hooknum == NF_INET_PRE_ROUTING || NF_CT_ASSERT(xt_hooknum(par) == NF_INET_PRE_ROUTING ||
par->hooknum == NF_INET_POST_ROUTING || xt_hooknum(par) == NF_INET_POST_ROUTING ||
par->hooknum == NF_INET_LOCAL_OUT || xt_hooknum(par) == NF_INET_LOCAL_OUT ||
par->hooknum == NF_INET_LOCAL_IN); xt_hooknum(par) == NF_INET_LOCAL_IN);
ct = nf_ct_get(skb, &ctinfo); ct = nf_ct_get(skb, &ctinfo);
netmask = ~(mr->range[0].min_ip ^ mr->range[0].max_ip); netmask = ~(mr->range[0].min_ip ^ mr->range[0].max_ip);
if (par->hooknum == NF_INET_PRE_ROUTING || if (xt_hooknum(par) == NF_INET_PRE_ROUTING ||
par->hooknum == NF_INET_LOCAL_OUT) xt_hooknum(par) == NF_INET_LOCAL_OUT)
new_ip = ip_hdr(skb)->daddr & ~netmask; new_ip = ip_hdr(skb)->daddr & ~netmask;
else else
new_ip = ip_hdr(skb)->saddr & ~netmask; new_ip = ip_hdr(skb)->saddr & ~netmask;
...@@ -96,7 +96,7 @@ netmap_tg4(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -96,7 +96,7 @@ netmap_tg4(struct sk_buff *skb, const struct xt_action_param *par)
newrange.max_proto = mr->range[0].max; newrange.max_proto = mr->range[0].max;
/* Hand modified range to generic setup. */ /* Hand modified range to generic setup. */
return nf_nat_setup_info(ct, &newrange, HOOK2MANIP(par->hooknum)); return nf_nat_setup_info(ct, &newrange, HOOK2MANIP(xt_hooknum(par)));
} }
static int netmap_tg4_check(const struct xt_tgchk_param *par) static int netmap_tg4_check(const struct xt_tgchk_param *par)
......
...@@ -25,8 +25,8 @@ static unsigned int ...@@ -25,8 +25,8 @@ static unsigned int
nflog_tg(struct sk_buff *skb, const struct xt_action_param *par) nflog_tg(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct xt_nflog_info *info = par->targinfo; const struct xt_nflog_info *info = par->targinfo;
struct net *net = xt_net(par);
struct nf_loginfo li; struct nf_loginfo li;
struct net *net = par->net;
li.type = NF_LOG_TYPE_ULOG; li.type = NF_LOG_TYPE_ULOG;
li.u.ulog.copy_len = info->len; li.u.ulog.copy_len = info->len;
...@@ -37,8 +37,8 @@ nflog_tg(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -37,8 +37,8 @@ nflog_tg(struct sk_buff *skb, const struct xt_action_param *par)
if (info->flags & XT_NFLOG_F_COPY_LEN) if (info->flags & XT_NFLOG_F_COPY_LEN)
li.u.ulog.flags |= NF_LOG_F_COPY_LEN; li.u.ulog.flags |= NF_LOG_F_COPY_LEN;
nfulnl_log_packet(net, par->family, par->hooknum, skb, par->in, nfulnl_log_packet(net, xt_family(par), xt_hooknum(par), skb,
par->out, &li, info->prefix); xt_in(par), xt_out(par), &li, info->prefix);
return XT_CONTINUE; return XT_CONTINUE;
} }
......
...@@ -43,7 +43,7 @@ nfqueue_tg_v1(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -43,7 +43,7 @@ nfqueue_tg_v1(struct sk_buff *skb, const struct xt_action_param *par)
if (info->queues_total > 1) { if (info->queues_total > 1) {
queue = nfqueue_hash(skb, queue, info->queues_total, queue = nfqueue_hash(skb, queue, info->queues_total,
par->family, jhash_initval); xt_family(par), jhash_initval);
} }
return NF_QUEUE_NR(queue); return NF_QUEUE_NR(queue);
} }
...@@ -98,7 +98,7 @@ nfqueue_tg_v3(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -98,7 +98,7 @@ nfqueue_tg_v3(struct sk_buff *skb, const struct xt_action_param *par)
queue = info->queuenum + cpu % info->queues_total; queue = info->queuenum + cpu % info->queues_total;
} else { } else {
queue = nfqueue_hash(skb, queue, info->queues_total, queue = nfqueue_hash(skb, queue, info->queues_total,
par->family, jhash_initval); xt_family(par), jhash_initval);
} }
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
static unsigned int static unsigned int
redirect_tg6(struct sk_buff *skb, const struct xt_action_param *par) redirect_tg6(struct sk_buff *skb, const struct xt_action_param *par)
{ {
return nf_nat_redirect_ipv6(skb, par->targinfo, par->hooknum); return nf_nat_redirect_ipv6(skb, par->targinfo, xt_hooknum(par));
} }
static int redirect_tg6_checkentry(const struct xt_tgchk_param *par) static int redirect_tg6_checkentry(const struct xt_tgchk_param *par)
...@@ -62,7 +62,7 @@ static int redirect_tg4_check(const struct xt_tgchk_param *par) ...@@ -62,7 +62,7 @@ static int redirect_tg4_check(const struct xt_tgchk_param *par)
static unsigned int static unsigned int
redirect_tg4(struct sk_buff *skb, const struct xt_action_param *par) redirect_tg4(struct sk_buff *skb, const struct xt_action_param *par)
{ {
return nf_nat_redirect_ipv4(skb, par->targinfo, par->hooknum); return nf_nat_redirect_ipv4(skb, par->targinfo, xt_hooknum(par));
} }
static struct xt_target redirect_tg_reg[] __read_mostly = { static struct xt_target redirect_tg_reg[] __read_mostly = {
......
...@@ -108,7 +108,7 @@ tcpmss_mangle_packet(struct sk_buff *skb, ...@@ -108,7 +108,7 @@ tcpmss_mangle_packet(struct sk_buff *skb,
return -1; return -1;
if (info->mss == XT_TCPMSS_CLAMP_PMTU) { if (info->mss == XT_TCPMSS_CLAMP_PMTU) {
struct net *net = par->net; struct net *net = xt_net(par);
unsigned int in_mtu = tcpmss_reverse_mtu(net, skb, family); unsigned int in_mtu = tcpmss_reverse_mtu(net, skb, family);
unsigned int min_mtu = min(dst_mtu(skb_dst(skb)), in_mtu); unsigned int min_mtu = min(dst_mtu(skb_dst(skb)), in_mtu);
...@@ -172,7 +172,7 @@ tcpmss_mangle_packet(struct sk_buff *skb, ...@@ -172,7 +172,7 @@ tcpmss_mangle_packet(struct sk_buff *skb,
* length IPv6 header of 60, ergo the default MSS value is 1220 * length IPv6 header of 60, ergo the default MSS value is 1220
* Since no MSS was provided, we must use the default values * Since no MSS was provided, we must use the default values
*/ */
if (par->family == NFPROTO_IPV4) if (xt_family(par) == NFPROTO_IPV4)
newmss = min(newmss, (u16)536); newmss = min(newmss, (u16)536);
else else
newmss = min(newmss, (u16)1220); newmss = min(newmss, (u16)1220);
......
...@@ -33,7 +33,7 @@ tee_tg4(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -33,7 +33,7 @@ tee_tg4(struct sk_buff *skb, const struct xt_action_param *par)
const struct xt_tee_tginfo *info = par->targinfo; const struct xt_tee_tginfo *info = par->targinfo;
int oif = info->priv ? info->priv->oif : 0; int oif = info->priv ? info->priv->oif : 0;
nf_dup_ipv4(par->net, skb, par->hooknum, &info->gw.in, oif); nf_dup_ipv4(xt_net(par), skb, xt_hooknum(par), &info->gw.in, oif);
return XT_CONTINUE; return XT_CONTINUE;
} }
...@@ -45,7 +45,7 @@ tee_tg6(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -45,7 +45,7 @@ tee_tg6(struct sk_buff *skb, const struct xt_action_param *par)
const struct xt_tee_tginfo *info = par->targinfo; const struct xt_tee_tginfo *info = par->targinfo;
int oif = info->priv ? info->priv->oif : 0; int oif = info->priv ? info->priv->oif : 0;
nf_dup_ipv6(par->net, skb, par->hooknum, &info->gw.in6, oif); nf_dup_ipv6(xt_net(par), skb, xt_hooknum(par), &info->gw.in6, oif);
return XT_CONTINUE; return XT_CONTINUE;
} }
......
...@@ -364,7 +364,8 @@ tproxy_tg4_v0(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -364,7 +364,8 @@ tproxy_tg4_v0(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct xt_tproxy_target_info *tgi = par->targinfo; const struct xt_tproxy_target_info *tgi = par->targinfo;
return tproxy_tg4(par->net, skb, tgi->laddr, tgi->lport, tgi->mark_mask, tgi->mark_value); return tproxy_tg4(xt_net(par), skb, tgi->laddr, tgi->lport,
tgi->mark_mask, tgi->mark_value);
} }
static unsigned int static unsigned int
...@@ -372,7 +373,8 @@ tproxy_tg4_v1(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -372,7 +373,8 @@ tproxy_tg4_v1(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct xt_tproxy_target_info_v1 *tgi = par->targinfo; const struct xt_tproxy_target_info_v1 *tgi = par->targinfo;
return tproxy_tg4(par->net, skb, tgi->laddr.ip, tgi->lport, tgi->mark_mask, tgi->mark_value); return tproxy_tg4(xt_net(par), skb, tgi->laddr.ip, tgi->lport,
tgi->mark_mask, tgi->mark_value);
} }
#ifdef XT_TPROXY_HAVE_IPV6 #ifdef XT_TPROXY_HAVE_IPV6
...@@ -442,7 +444,7 @@ tproxy_handle_time_wait6(struct sk_buff *skb, int tproto, int thoff, ...@@ -442,7 +444,7 @@ tproxy_handle_time_wait6(struct sk_buff *skb, int tproto, int thoff,
* to a listener socket if there's one */ * to a listener socket if there's one */
struct sock *sk2; struct sock *sk2;
sk2 = nf_tproxy_get_sock_v6(par->net, skb, thoff, hp, tproto, sk2 = nf_tproxy_get_sock_v6(xt_net(par), skb, thoff, hp, tproto,
&iph->saddr, &iph->saddr,
tproxy_laddr6(skb, &tgi->laddr.in6, &iph->daddr), tproxy_laddr6(skb, &tgi->laddr.in6, &iph->daddr),
hp->source, hp->source,
...@@ -485,10 +487,10 @@ tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -485,10 +487,10 @@ tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par)
* addresses, this happens if the redirect already happened * addresses, this happens if the redirect already happened
* and the current packet belongs to an already established * and the current packet belongs to an already established
* connection */ * connection */
sk = nf_tproxy_get_sock_v6(par->net, skb, thoff, hp, tproto, sk = nf_tproxy_get_sock_v6(xt_net(par), skb, thoff, hp, tproto,
&iph->saddr, &iph->daddr, &iph->saddr, &iph->daddr,
hp->source, hp->dest, hp->source, hp->dest,
par->in, NFT_LOOKUP_ESTABLISHED); xt_in(par), NFT_LOOKUP_ESTABLISHED);
laddr = tproxy_laddr6(skb, &tgi->laddr.in6, &iph->daddr); laddr = tproxy_laddr6(skb, &tgi->laddr.in6, &iph->daddr);
lport = tgi->lport ? tgi->lport : hp->dest; lport = tgi->lport ? tgi->lport : hp->dest;
...@@ -500,10 +502,10 @@ tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -500,10 +502,10 @@ tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par)
else if (!sk) else if (!sk)
/* no there's no established connection, check if /* no there's no established connection, check if
* there's a listener on the redirected addr/port */ * there's a listener on the redirected addr/port */
sk = nf_tproxy_get_sock_v6(par->net, skb, thoff, hp, sk = nf_tproxy_get_sock_v6(xt_net(par), skb, thoff, hp,
tproto, &iph->saddr, laddr, tproto, &iph->saddr, laddr,
hp->source, lport, hp->source, lport,
par->in, NFT_LOOKUP_LISTENER); xt_in(par), NFT_LOOKUP_LISTENER);
/* NOTE: assign_sock consumes our sk reference */ /* NOTE: assign_sock consumes our sk reference */
if (sk && tproxy_sk_is_transparent(sk)) { if (sk && tproxy_sk_is_transparent(sk)) {
......
...@@ -125,7 +125,7 @@ static inline bool match_type(struct net *net, const struct net_device *dev, ...@@ -125,7 +125,7 @@ static inline bool match_type(struct net *net, const struct net_device *dev,
static bool static bool
addrtype_mt_v0(const struct sk_buff *skb, struct xt_action_param *par) addrtype_mt_v0(const struct sk_buff *skb, struct xt_action_param *par)
{ {
struct net *net = par->net; struct net *net = xt_net(par);
const struct xt_addrtype_info *info = par->matchinfo; const struct xt_addrtype_info *info = par->matchinfo;
const struct iphdr *iph = ip_hdr(skb); const struct iphdr *iph = ip_hdr(skb);
bool ret = true; bool ret = true;
...@@ -143,19 +143,19 @@ addrtype_mt_v0(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -143,19 +143,19 @@ addrtype_mt_v0(const struct sk_buff *skb, struct xt_action_param *par)
static bool static bool
addrtype_mt_v1(const struct sk_buff *skb, struct xt_action_param *par) addrtype_mt_v1(const struct sk_buff *skb, struct xt_action_param *par)
{ {
struct net *net = par->net; struct net *net = xt_net(par);
const struct xt_addrtype_info_v1 *info = par->matchinfo; const struct xt_addrtype_info_v1 *info = par->matchinfo;
const struct iphdr *iph; const struct iphdr *iph;
const struct net_device *dev = NULL; const struct net_device *dev = NULL;
bool ret = true; bool ret = true;
if (info->flags & XT_ADDRTYPE_LIMIT_IFACE_IN) if (info->flags & XT_ADDRTYPE_LIMIT_IFACE_IN)
dev = par->in; dev = xt_in(par);
else if (info->flags & XT_ADDRTYPE_LIMIT_IFACE_OUT) else if (info->flags & XT_ADDRTYPE_LIMIT_IFACE_OUT)
dev = par->out; dev = xt_out(par);
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
if (par->family == NFPROTO_IPV6) if (xt_family(par) == NFPROTO_IPV6)
return addrtype_mt6(net, dev, skb, info); return addrtype_mt6(net, dev, skb, info);
#endif #endif
iph = ip_hdr(skb); iph = ip_hdr(skb);
......
...@@ -112,7 +112,7 @@ xt_cluster_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -112,7 +112,7 @@ xt_cluster_mt(const struct sk_buff *skb, struct xt_action_param *par)
* know, matches should not alter packets, but we are doing this here * know, matches should not alter packets, but we are doing this here
* because we would need to add a PKTTYPE target for this sole purpose. * because we would need to add a PKTTYPE target for this sole purpose.
*/ */
if (!xt_cluster_is_multicast_addr(skb, par->family) && if (!xt_cluster_is_multicast_addr(skb, xt_family(par)) &&
skb->pkt_type == PACKET_MULTICAST) { skb->pkt_type == PACKET_MULTICAST) {
pskb->pkt_type = PACKET_HOST; pskb->pkt_type = PACKET_HOST;
} }
......
...@@ -317,7 +317,7 @@ static int count_them(struct net *net, ...@@ -317,7 +317,7 @@ static int count_them(struct net *net,
static bool static bool
connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par) connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
{ {
struct net *net = par->net; struct net *net = xt_net(par);
const struct xt_connlimit_info *info = par->matchinfo; const struct xt_connlimit_info *info = par->matchinfo;
union nf_inet_addr addr; union nf_inet_addr addr;
struct nf_conntrack_tuple tuple; struct nf_conntrack_tuple tuple;
...@@ -332,11 +332,11 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -332,11 +332,11 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
tuple_ptr = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple; tuple_ptr = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
zone = nf_ct_zone(ct); zone = nf_ct_zone(ct);
} else if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb), } else if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb),
par->family, net, &tuple)) { xt_family(par), net, &tuple)) {
goto hotdrop; goto hotdrop;
} }
if (par->family == NFPROTO_IPV6) { if (xt_family(par) == NFPROTO_IPV6) {
const struct ipv6hdr *iph = ipv6_hdr(skb); const struct ipv6hdr *iph = ipv6_hdr(skb);
memcpy(&addr.ip6, (info->flags & XT_CONNLIMIT_DADDR) ? memcpy(&addr.ip6, (info->flags & XT_CONNLIMIT_DADDR) ?
&iph->daddr : &iph->saddr, sizeof(addr.ip6)); &iph->daddr : &iph->saddr, sizeof(addr.ip6));
...@@ -347,7 +347,7 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -347,7 +347,7 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
} }
connections = count_them(net, info->data, tuple_ptr, &addr, connections = count_them(net, info->data, tuple_ptr, &addr,
&info->mask, par->family, zone); &info->mask, xt_family(par), zone);
if (connections == 0) if (connections == 0)
/* kmalloc failed, drop it entirely */ /* kmalloc failed, drop it entirely */
goto hotdrop; goto hotdrop;
......
...@@ -200,22 +200,22 @@ conntrack_mt(const struct sk_buff *skb, struct xt_action_param *par, ...@@ -200,22 +200,22 @@ conntrack_mt(const struct sk_buff *skb, struct xt_action_param *par,
return false; return false;
if (info->match_flags & XT_CONNTRACK_ORIGSRC) if (info->match_flags & XT_CONNTRACK_ORIGSRC)
if (conntrack_mt_origsrc(ct, info, par->family) ^ if (conntrack_mt_origsrc(ct, info, xt_family(par)) ^
!(info->invert_flags & XT_CONNTRACK_ORIGSRC)) !(info->invert_flags & XT_CONNTRACK_ORIGSRC))
return false; return false;
if (info->match_flags & XT_CONNTRACK_ORIGDST) if (info->match_flags & XT_CONNTRACK_ORIGDST)
if (conntrack_mt_origdst(ct, info, par->family) ^ if (conntrack_mt_origdst(ct, info, xt_family(par)) ^
!(info->invert_flags & XT_CONNTRACK_ORIGDST)) !(info->invert_flags & XT_CONNTRACK_ORIGDST))
return false; return false;
if (info->match_flags & XT_CONNTRACK_REPLSRC) if (info->match_flags & XT_CONNTRACK_REPLSRC)
if (conntrack_mt_replsrc(ct, info, par->family) ^ if (conntrack_mt_replsrc(ct, info, xt_family(par)) ^
!(info->invert_flags & XT_CONNTRACK_REPLSRC)) !(info->invert_flags & XT_CONNTRACK_REPLSRC))
return false; return false;
if (info->match_flags & XT_CONNTRACK_REPLDST) if (info->match_flags & XT_CONNTRACK_REPLDST)
if (conntrack_mt_repldst(ct, info, par->family) ^ if (conntrack_mt_repldst(ct, info, xt_family(par)) ^
!(info->invert_flags & XT_CONNTRACK_REPLDST)) !(info->invert_flags & XT_CONNTRACK_REPLDST))
return false; return false;
......
...@@ -24,12 +24,12 @@ static bool devgroup_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -24,12 +24,12 @@ static bool devgroup_mt(const struct sk_buff *skb, struct xt_action_param *par)
const struct xt_devgroup_info *info = par->matchinfo; const struct xt_devgroup_info *info = par->matchinfo;
if (info->flags & XT_DEVGROUP_MATCH_SRC && if (info->flags & XT_DEVGROUP_MATCH_SRC &&
(((info->src_group ^ par->in->group) & info->src_mask ? 1 : 0) ^ (((info->src_group ^ xt_in(par)->group) & info->src_mask ? 1 : 0) ^
((info->flags & XT_DEVGROUP_INVERT_SRC) ? 1 : 0))) ((info->flags & XT_DEVGROUP_INVERT_SRC) ? 1 : 0)))
return false; return false;
if (info->flags & XT_DEVGROUP_MATCH_DST && if (info->flags & XT_DEVGROUP_MATCH_DST &&
(((info->dst_group ^ par->out->group) & info->dst_mask ? 1 : 0) ^ (((info->dst_group ^ xt_out(par)->group) & info->dst_mask ? 1 : 0) ^
((info->flags & XT_DEVGROUP_INVERT_DST) ? 1 : 0))) ((info->flags & XT_DEVGROUP_INVERT_DST) ? 1 : 0)))
return false; return false;
......
...@@ -58,7 +58,7 @@ static bool tos_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -58,7 +58,7 @@ static bool tos_mt(const struct sk_buff *skb, struct xt_action_param *par)
{ {
const struct xt_tos_match_info *info = par->matchinfo; const struct xt_tos_match_info *info = par->matchinfo;
if (par->family == NFPROTO_IPV4) if (xt_family(par) == NFPROTO_IPV4)
return ((ip_hdr(skb)->tos & info->tos_mask) == return ((ip_hdr(skb)->tos & info->tos_mask) ==
info->tos_value) ^ !!info->invert; info->tos_value) ^ !!info->invert;
else else
......
...@@ -48,9 +48,9 @@ static bool ...@@ -48,9 +48,9 @@ static bool
ipvs_mt(const struct sk_buff *skb, struct xt_action_param *par) ipvs_mt(const struct sk_buff *skb, struct xt_action_param *par)
{ {
const struct xt_ipvs_mtinfo *data = par->matchinfo; const struct xt_ipvs_mtinfo *data = par->matchinfo;
struct netns_ipvs *ipvs = net_ipvs(par->net); struct netns_ipvs *ipvs = net_ipvs(xt_net(par));
/* ipvs_mt_check ensures that family is only NFPROTO_IPV[46]. */ /* ipvs_mt_check ensures that family is only NFPROTO_IPV[46]. */
const u_int8_t family = par->family; const u_int8_t family = xt_family(par);
struct ip_vs_iphdr iph; struct ip_vs_iphdr iph;
struct ip_vs_protocol *pp; struct ip_vs_protocol *pp;
struct ip_vs_conn *cp; struct ip_vs_conn *cp;
......
...@@ -26,7 +26,7 @@ static bool nfacct_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -26,7 +26,7 @@ static bool nfacct_mt(const struct sk_buff *skb, struct xt_action_param *par)
nfnl_acct_update(skb, info->nfacct); nfnl_acct_update(skb, info->nfacct);
overquota = nfnl_acct_overquota(par->net, skb, info->nfacct); overquota = nfnl_acct_overquota(xt_net(par), skb, info->nfacct);
return overquota == NFACCT_UNDERQUOTA ? false : true; return overquota == NFACCT_UNDERQUOTA ? false : true;
} }
......
...@@ -201,7 +201,7 @@ xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p) ...@@ -201,7 +201,7 @@ xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p)
unsigned char opts[MAX_IPOPTLEN]; unsigned char opts[MAX_IPOPTLEN];
const struct xt_osf_finger *kf; const struct xt_osf_finger *kf;
const struct xt_osf_user_finger *f; const struct xt_osf_user_finger *f;
struct net *net = p->net; struct net *net = xt_net(p);
if (!info) if (!info)
return false; return false;
...@@ -326,8 +326,8 @@ xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p) ...@@ -326,8 +326,8 @@ xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p)
fcount++; fcount++;
if (info->flags & XT_OSF_LOG) if (info->flags & XT_OSF_LOG)
nf_log_packet(net, p->family, p->hooknum, skb, nf_log_packet(net, xt_family(p), xt_hooknum(p), skb,
p->in, p->out, NULL, xt_in(p), xt_out(p), NULL,
"%s [%s:%s] : %pI4:%d -> %pI4:%d hops=%d\n", "%s [%s:%s] : %pI4:%d -> %pI4:%d hops=%d\n",
f->genre, f->version, f->subtype, f->genre, f->version, f->subtype,
&ip->saddr, ntohs(tcp->source), &ip->saddr, ntohs(tcp->source),
...@@ -341,8 +341,8 @@ xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p) ...@@ -341,8 +341,8 @@ xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p)
rcu_read_unlock(); rcu_read_unlock();
if (!fcount && (info->flags & XT_OSF_LOG)) if (!fcount && (info->flags & XT_OSF_LOG))
nf_log_packet(net, p->family, p->hooknum, skb, p->in, nf_log_packet(net, xt_family(p), xt_hooknum(p), skb, xt_in(p),
p->out, NULL, xt_out(p), NULL,
"Remote OS is not known: %pI4:%u -> %pI4:%u\n", "Remote OS is not known: %pI4:%u -> %pI4:%u\n",
&ip->saddr, ntohs(tcp->source), &ip->saddr, ntohs(tcp->source),
&ip->daddr, ntohs(tcp->dest)); &ip->daddr, ntohs(tcp->dest));
......
...@@ -63,7 +63,7 @@ owner_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -63,7 +63,7 @@ owner_mt(const struct sk_buff *skb, struct xt_action_param *par)
const struct xt_owner_match_info *info = par->matchinfo; const struct xt_owner_match_info *info = par->matchinfo;
const struct file *filp; const struct file *filp;
struct sock *sk = skb_to_full_sk(skb); struct sock *sk = skb_to_full_sk(skb);
struct net *net = par->net; struct net *net = xt_net(par);
if (sk == NULL || sk->sk_socket == NULL) if (sk == NULL || sk->sk_socket == NULL)
return (info->match ^ info->invert) == 0; return (info->match ^ info->invert) == 0;
......
...@@ -30,10 +30,10 @@ pkttype_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -30,10 +30,10 @@ pkttype_mt(const struct sk_buff *skb, struct xt_action_param *par)
if (skb->pkt_type != PACKET_LOOPBACK) if (skb->pkt_type != PACKET_LOOPBACK)
type = skb->pkt_type; type = skb->pkt_type;
else if (par->family == NFPROTO_IPV4 && else if (xt_family(par) == NFPROTO_IPV4 &&
ipv4_is_multicast(ip_hdr(skb)->daddr)) ipv4_is_multicast(ip_hdr(skb)->daddr))
type = PACKET_MULTICAST; type = PACKET_MULTICAST;
else if (par->family == NFPROTO_IPV6 && else if (xt_family(par) == NFPROTO_IPV6 &&
ipv6_hdr(skb)->daddr.s6_addr[0] == 0xFF) ipv6_hdr(skb)->daddr.s6_addr[0] == 0xFF)
type = PACKET_MULTICAST; type = PACKET_MULTICAST;
else else
......
...@@ -116,9 +116,9 @@ policy_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -116,9 +116,9 @@ policy_mt(const struct sk_buff *skb, struct xt_action_param *par)
int ret; int ret;
if (info->flags & XT_POLICY_MATCH_IN) if (info->flags & XT_POLICY_MATCH_IN)
ret = match_policy_in(skb, info, par->family); ret = match_policy_in(skb, info, xt_family(par));
else else
ret = match_policy_out(skb, info, par->family); ret = match_policy_out(skb, info, xt_family(par));
if (ret < 0) if (ret < 0)
ret = info->flags & XT_POLICY_MATCH_NONE ? true : false; ret = info->flags & XT_POLICY_MATCH_NONE ? true : false;
......
...@@ -236,7 +236,7 @@ static void recent_table_flush(struct recent_table *t) ...@@ -236,7 +236,7 @@ static void recent_table_flush(struct recent_table *t)
static bool static bool
recent_mt(const struct sk_buff *skb, struct xt_action_param *par) recent_mt(const struct sk_buff *skb, struct xt_action_param *par)
{ {
struct net *net = par->net; struct net *net = xt_net(par);
struct recent_net *recent_net = recent_pernet(net); struct recent_net *recent_net = recent_pernet(net);
const struct xt_recent_mtinfo_v1 *info = par->matchinfo; const struct xt_recent_mtinfo_v1 *info = par->matchinfo;
struct recent_table *t; struct recent_table *t;
...@@ -245,7 +245,7 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -245,7 +245,7 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par)
u_int8_t ttl; u_int8_t ttl;
bool ret = info->invert; bool ret = info->invert;
if (par->family == NFPROTO_IPV4) { if (xt_family(par) == NFPROTO_IPV4) {
const struct iphdr *iph = ip_hdr(skb); const struct iphdr *iph = ip_hdr(skb);
if (info->side == XT_RECENT_DEST) if (info->side == XT_RECENT_DEST)
...@@ -266,7 +266,7 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -266,7 +266,7 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par)
} }
/* use TTL as seen before forwarding */ /* use TTL as seen before forwarding */
if (par->out != NULL && skb->sk == NULL) if (xt_out(par) != NULL && skb->sk == NULL)
ttl++; ttl++;
spin_lock_bh(&recent_lock); spin_lock_bh(&recent_lock);
...@@ -274,12 +274,12 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -274,12 +274,12 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par)
nf_inet_addr_mask(&addr, &addr_mask, &t->mask); nf_inet_addr_mask(&addr, &addr_mask, &t->mask);
e = recent_entry_lookup(t, &addr_mask, par->family, e = recent_entry_lookup(t, &addr_mask, xt_family(par),
(info->check_set & XT_RECENT_TTL) ? ttl : 0); (info->check_set & XT_RECENT_TTL) ? ttl : 0);
if (e == NULL) { if (e == NULL) {
if (!(info->check_set & XT_RECENT_SET)) if (!(info->check_set & XT_RECENT_SET))
goto out; goto out;
e = recent_entry_init(t, &addr_mask, par->family, ttl); e = recent_entry_init(t, &addr_mask, xt_family(par), ttl);
if (e == NULL) if (e == NULL)
par->hotdrop = true; par->hotdrop = true;
ret = !ret; ret = !ret;
......
...@@ -55,7 +55,7 @@ set_match_v0(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -55,7 +55,7 @@ set_match_v0(const struct sk_buff *skb, struct xt_action_param *par)
{ {
const struct xt_set_info_match_v0 *info = par->matchinfo; const struct xt_set_info_match_v0 *info = par->matchinfo;
ADT_OPT(opt, par->family, info->match_set.u.compat.dim, ADT_OPT(opt, xt_family(par), info->match_set.u.compat.dim,
info->match_set.u.compat.flags, 0, UINT_MAX); info->match_set.u.compat.flags, 0, UINT_MAX);
return match_set(info->match_set.index, skb, par, &opt, return match_set(info->match_set.index, skb, par, &opt,
...@@ -118,7 +118,7 @@ set_match_v1(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -118,7 +118,7 @@ set_match_v1(const struct sk_buff *skb, struct xt_action_param *par)
{ {
const struct xt_set_info_match_v1 *info = par->matchinfo; const struct xt_set_info_match_v1 *info = par->matchinfo;
ADT_OPT(opt, par->family, info->match_set.dim, ADT_OPT(opt, xt_family(par), info->match_set.dim,
info->match_set.flags, 0, UINT_MAX); info->match_set.flags, 0, UINT_MAX);
if (opt.flags & IPSET_RETURN_NOMATCH) if (opt.flags & IPSET_RETURN_NOMATCH)
...@@ -184,7 +184,7 @@ set_match_v3(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -184,7 +184,7 @@ set_match_v3(const struct sk_buff *skb, struct xt_action_param *par)
const struct xt_set_info_match_v3 *info = par->matchinfo; const struct xt_set_info_match_v3 *info = par->matchinfo;
int ret; int ret;
ADT_OPT(opt, par->family, info->match_set.dim, ADT_OPT(opt, xt_family(par), info->match_set.dim,
info->match_set.flags, info->flags, UINT_MAX); info->match_set.flags, info->flags, UINT_MAX);
if (info->packets.op != IPSET_COUNTER_NONE || if (info->packets.op != IPSET_COUNTER_NONE ||
...@@ -231,7 +231,7 @@ set_match_v4(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -231,7 +231,7 @@ set_match_v4(const struct sk_buff *skb, struct xt_action_param *par)
const struct xt_set_info_match_v4 *info = par->matchinfo; const struct xt_set_info_match_v4 *info = par->matchinfo;
int ret; int ret;
ADT_OPT(opt, par->family, info->match_set.dim, ADT_OPT(opt, xt_family(par), info->match_set.dim,
info->match_set.flags, info->flags, UINT_MAX); info->match_set.flags, info->flags, UINT_MAX);
if (info->packets.op != IPSET_COUNTER_NONE || if (info->packets.op != IPSET_COUNTER_NONE ||
...@@ -259,9 +259,9 @@ set_target_v0(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -259,9 +259,9 @@ set_target_v0(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct xt_set_info_target_v0 *info = par->targinfo; const struct xt_set_info_target_v0 *info = par->targinfo;
ADT_OPT(add_opt, par->family, info->add_set.u.compat.dim, ADT_OPT(add_opt, xt_family(par), info->add_set.u.compat.dim,
info->add_set.u.compat.flags, 0, UINT_MAX); info->add_set.u.compat.flags, 0, UINT_MAX);
ADT_OPT(del_opt, par->family, info->del_set.u.compat.dim, ADT_OPT(del_opt, xt_family(par), info->del_set.u.compat.dim,
info->del_set.u.compat.flags, 0, UINT_MAX); info->del_set.u.compat.flags, 0, UINT_MAX);
if (info->add_set.index != IPSET_INVALID_ID) if (info->add_set.index != IPSET_INVALID_ID)
...@@ -332,9 +332,9 @@ set_target_v1(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -332,9 +332,9 @@ set_target_v1(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct xt_set_info_target_v1 *info = par->targinfo; const struct xt_set_info_target_v1 *info = par->targinfo;
ADT_OPT(add_opt, par->family, info->add_set.dim, ADT_OPT(add_opt, xt_family(par), info->add_set.dim,
info->add_set.flags, 0, UINT_MAX); info->add_set.flags, 0, UINT_MAX);
ADT_OPT(del_opt, par->family, info->del_set.dim, ADT_OPT(del_opt, xt_family(par), info->del_set.dim,
info->del_set.flags, 0, UINT_MAX); info->del_set.flags, 0, UINT_MAX);
if (info->add_set.index != IPSET_INVALID_ID) if (info->add_set.index != IPSET_INVALID_ID)
...@@ -401,9 +401,9 @@ set_target_v2(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -401,9 +401,9 @@ set_target_v2(struct sk_buff *skb, const struct xt_action_param *par)
{ {
const struct xt_set_info_target_v2 *info = par->targinfo; const struct xt_set_info_target_v2 *info = par->targinfo;
ADT_OPT(add_opt, par->family, info->add_set.dim, ADT_OPT(add_opt, xt_family(par), info->add_set.dim,
info->add_set.flags, info->flags, info->timeout); info->add_set.flags, info->flags, info->timeout);
ADT_OPT(del_opt, par->family, info->del_set.dim, ADT_OPT(del_opt, xt_family(par), info->del_set.dim,
info->del_set.flags, 0, UINT_MAX); info->del_set.flags, 0, UINT_MAX);
/* Normalize to fit into jiffies */ /* Normalize to fit into jiffies */
...@@ -429,11 +429,11 @@ set_target_v3(struct sk_buff *skb, const struct xt_action_param *par) ...@@ -429,11 +429,11 @@ set_target_v3(struct sk_buff *skb, const struct xt_action_param *par)
const struct xt_set_info_target_v3 *info = par->targinfo; const struct xt_set_info_target_v3 *info = par->targinfo;
int ret; int ret;
ADT_OPT(add_opt, par->family, info->add_set.dim, ADT_OPT(add_opt, xt_family(par), info->add_set.dim,
info->add_set.flags, info->flags, info->timeout); info->add_set.flags, info->flags, info->timeout);
ADT_OPT(del_opt, par->family, info->del_set.dim, ADT_OPT(del_opt, xt_family(par), info->del_set.dim,
info->del_set.flags, 0, UINT_MAX); info->del_set.flags, 0, UINT_MAX);
ADT_OPT(map_opt, par->family, info->map_set.dim, ADT_OPT(map_opt, xt_family(par), info->map_set.dim,
info->map_set.flags, 0, UINT_MAX); info->map_set.flags, 0, UINT_MAX);
/* Normalize to fit into jiffies */ /* Normalize to fit into jiffies */
......
...@@ -57,7 +57,7 @@ socket_match(const struct sk_buff *skb, struct xt_action_param *par, ...@@ -57,7 +57,7 @@ socket_match(const struct sk_buff *skb, struct xt_action_param *par,
struct sock *sk = skb->sk; struct sock *sk = skb->sk;
if (!sk) if (!sk)
sk = nf_sk_lookup_slow_v4(par->net, skb, par->in); sk = nf_sk_lookup_slow_v4(xt_net(par), skb, xt_in(par));
if (sk) { if (sk) {
bool wildcard; bool wildcard;
bool transparent = true; bool transparent = true;
...@@ -114,7 +114,7 @@ socket_mt6_v1_v2_v3(const struct sk_buff *skb, struct xt_action_param *par) ...@@ -114,7 +114,7 @@ socket_mt6_v1_v2_v3(const struct sk_buff *skb, struct xt_action_param *par)
struct sock *sk = skb->sk; struct sock *sk = skb->sk;
if (!sk) if (!sk)
sk = nf_sk_lookup_slow_v6(par->net, skb, par->in); sk = nf_sk_lookup_slow_v6(xt_net(par), skb, xt_in(par));
if (sk) { if (sk) {
bool wildcard; bool wildcard;
bool transparent = true; bool transparent = true;
......
...@@ -213,6 +213,12 @@ static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a, ...@@ -213,6 +213,12 @@ static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a,
int ret = 0, result = 0; int ret = 0, result = 0;
struct tcf_ipt *ipt = to_ipt(a); struct tcf_ipt *ipt = to_ipt(a);
struct xt_action_param par; struct xt_action_param par;
struct nf_hook_state state = {
.net = dev_net(skb->dev),
.in = skb->dev,
.hook = ipt->tcfi_hook,
.pf = NFPROTO_IPV4,
};
if (skb_unclone(skb, GFP_ATOMIC)) if (skb_unclone(skb, GFP_ATOMIC))
return TC_ACT_UNSPEC; return TC_ACT_UNSPEC;
...@@ -226,13 +232,9 @@ static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a, ...@@ -226,13 +232,9 @@ static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a,
* worry later - danger - this API seems to have changed * worry later - danger - this API seems to have changed
* from earlier kernels * from earlier kernels
*/ */
par.net = dev_net(skb->dev); par.state = &state;
par.in = skb->dev;
par.out = NULL;
par.hooknum = ipt->tcfi_hook;
par.target = ipt->tcfi_t->u.kernel.target; par.target = ipt->tcfi_t->u.kernel.target;
par.targinfo = ipt->tcfi_t->data; par.targinfo = ipt->tcfi_t->data;
par.family = NFPROTO_IPV4;
ret = par.target->target(skb, &par); ret = par.target->target(skb, &par);
switch (ret) { switch (ret) {
......
...@@ -57,17 +57,20 @@ static int em_ipset_match(struct sk_buff *skb, struct tcf_ematch *em, ...@@ -57,17 +57,20 @@ static int em_ipset_match(struct sk_buff *skb, struct tcf_ematch *em,
struct xt_action_param acpar; struct xt_action_param acpar;
const struct xt_set_info *set = (const void *) em->data; const struct xt_set_info *set = (const void *) em->data;
struct net_device *dev, *indev = NULL; struct net_device *dev, *indev = NULL;
struct nf_hook_state state = {
.net = em->net,
};
int ret, network_offset; int ret, network_offset;
switch (tc_skb_protocol(skb)) { switch (tc_skb_protocol(skb)) {
case htons(ETH_P_IP): case htons(ETH_P_IP):
acpar.family = NFPROTO_IPV4; state.pf = NFPROTO_IPV4;
if (!pskb_network_may_pull(skb, sizeof(struct iphdr))) if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
return 0; return 0;
acpar.thoff = ip_hdrlen(skb); acpar.thoff = ip_hdrlen(skb);
break; break;
case htons(ETH_P_IPV6): case htons(ETH_P_IPV6):
acpar.family = NFPROTO_IPV6; state.pf = NFPROTO_IPV6;
if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr))) if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr)))
return 0; return 0;
/* doesn't call ipv6_find_hdr() because ipset doesn't use thoff, yet */ /* doesn't call ipv6_find_hdr() because ipset doesn't use thoff, yet */
...@@ -77,9 +80,7 @@ static int em_ipset_match(struct sk_buff *skb, struct tcf_ematch *em, ...@@ -77,9 +80,7 @@ static int em_ipset_match(struct sk_buff *skb, struct tcf_ematch *em,
return 0; return 0;
} }
acpar.hooknum = 0; opt.family = state.pf;
opt.family = acpar.family;
opt.dim = set->dim; opt.dim = set->dim;
opt.flags = set->flags; opt.flags = set->flags;
opt.cmdflags = 0; opt.cmdflags = 0;
...@@ -95,9 +96,9 @@ static int em_ipset_match(struct sk_buff *skb, struct tcf_ematch *em, ...@@ -95,9 +96,9 @@ static int em_ipset_match(struct sk_buff *skb, struct tcf_ematch *em,
if (skb->skb_iif) if (skb->skb_iif)
indev = dev_get_by_index_rcu(em->net, skb->skb_iif); indev = dev_get_by_index_rcu(em->net, skb->skb_iif);
acpar.net = em->net; state.in = indev ? indev : dev;
acpar.in = indev ? indev : dev; state.out = dev;
acpar.out = dev; acpar.state = &state;
ret = ip_set_test(set->index, skb, &acpar, &opt); ret = ip_set_test(set->index, skb, &acpar, &opt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment