Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9dff2c96 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller
Browse files

netfilter: Use nf_hook_state.net



Instead of saying "net = dev_net(state->in?state->in:state->out)"
just say "state->net".  As that information is now availabe,
much less confusing and much less error prone.

Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 29a26a56
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ ebt_in_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
	    const struct nf_hook_state *state)
{
	return ebt_do_table(ops->hooknum, skb, state->in, state->out,
			    dev_net(state->in)->xt.frame_filter);
			    state->net->xt.frame_filter);
}

static unsigned int
@@ -69,7 +69,7 @@ ebt_out_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
	     const struct nf_hook_state *state)
{
	return ebt_do_table(ops->hooknum, skb, state->in, state->out,
			    dev_net(state->out)->xt.frame_filter);
			    state->net->xt.frame_filter);
}

static struct nf_hook_ops ebt_ops_filter[] __read_mostly = {
+2 −2
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ ebt_nat_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
	   const struct nf_hook_state *state)
{
	return ebt_do_table(ops->hooknum, skb, state->in, state->out,
			    dev_net(state->in)->xt.frame_nat);
			    state->net->xt.frame_nat);
}

static unsigned int
@@ -69,7 +69,7 @@ ebt_nat_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
	    const struct nf_hook_state *state)
{
	return ebt_do_table(ops->hooknum, skb, state->in, state->out,
			    dev_net(state->out)->xt.frame_nat);
			    state->net->xt.frame_nat);
}

static struct nf_hook_ops ebt_ops_nat[] __read_mostly = {
+1 −3
Original line number Diff line number Diff line
@@ -30,10 +30,8 @@ static unsigned int
arptable_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
		     const struct nf_hook_state *state)
{
	const struct net *net = dev_net(state->in ? state->in : state->out);

	return arpt_do_table(skb, ops->hooknum, state,
			     net->ipv4.arptable_filter);
			     state->net->ipv4.arptable_filter);
}

static struct nf_hook_ops *arpfilter_ops __read_mostly;
+4 −4
Original line number Diff line number Diff line
@@ -246,7 +246,8 @@ get_chainname_rulenum(const struct ipt_entry *s, const struct ipt_entry *e,
	return 0;
}

static void trace_packet(const struct sk_buff *skb,
static void trace_packet(struct net *net,
			 const struct sk_buff *skb,
			 unsigned int hook,
			 const struct net_device *in,
			 const struct net_device *out,
@@ -258,7 +259,6 @@ static void trace_packet(const struct sk_buff *skb,
	const char *hookname, *chainname, *comment;
	const struct ipt_entry *iter;
	unsigned int rulenum = 0;
	struct net *net = dev_net(in ? in : out);

	root = get_entry(private->entries, private->hook_entry[hook]);

@@ -378,8 +378,8 @@ ipt_do_table(struct sk_buff *skb,
#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
		/* The packet is traced: log it */
		if (unlikely(skb->nf_trace))
			trace_packet(skb, hook, state->in, state->out,
				     table->name, private, e);
			trace_packet(state->net, skb, hook, state->in,
				     state->out, table->name, private, e);
#endif
		/* Standard target? */
		if (!t->u.kernel.target->target) {
+1 −1
Original line number Diff line number Diff line
@@ -514,7 +514,7 @@ arp_mangle(const struct nf_hook_ops *ops,
	struct arphdr *arp = arp_hdr(skb);
	struct arp_payload *payload;
	struct clusterip_config *c;
	struct net *net = dev_net(state->in ? state->in : state->out);
	struct net *net = state->net;

	/* we don't care about non-ethernet and non-ipv4 ARP */
	if (arp->ar_hrd != htons(ARPHRD_ETHER) ||
Loading