|
@@ -256,7 +256,7 @@ void nf_bridge_update_protocol(struct sk_buff *skb)
|
|
|
* don't, we use the neighbour framework to find out. In both cases, we make
|
|
|
* sure that br_handle_frame_finish() is called afterwards.
|
|
|
*/
|
|
|
-int br_nf_pre_routing_finish_bridge(struct sock *sk, struct sk_buff *skb)
|
|
|
+int br_nf_pre_routing_finish_bridge(struct net *net, struct sock *sk, struct sk_buff *skb)
|
|
|
{
|
|
|
struct neighbour *neigh;
|
|
|
struct dst_entry *dst;
|
|
@@ -273,7 +273,7 @@ int br_nf_pre_routing_finish_bridge(struct sock *sk, struct sk_buff *skb)
|
|
|
if (neigh->hh.hh_len) {
|
|
|
neigh_hh_bridge(&neigh->hh, skb);
|
|
|
skb->dev = nf_bridge->physindev;
|
|
|
- ret = br_handle_frame_finish(sk, skb);
|
|
|
+ ret = br_handle_frame_finish(net, sk, skb);
|
|
|
} else {
|
|
|
/* the neighbour function below overwrites the complete
|
|
|
* MAC header, so we save the Ethernet source address and
|
|
@@ -342,7 +342,7 @@ br_nf_ipv4_daddr_was_changed(const struct sk_buff *skb,
|
|
|
* device, we proceed as if ip_route_input() succeeded. If it differs from the
|
|
|
* logical bridge port or if ip_route_output_key() fails we drop the packet.
|
|
|
*/
|
|
|
-static int br_nf_pre_routing_finish(struct sock *sk, struct sk_buff *skb)
|
|
|
+static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
|
|
{
|
|
|
struct net_device *dev = skb->dev;
|
|
|
struct iphdr *iph = ip_hdr(skb);
|
|
@@ -371,7 +371,7 @@ static int br_nf_pre_routing_finish(struct sock *sk, struct sk_buff *skb)
|
|
|
if (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev))
|
|
|
goto free_skb;
|
|
|
|
|
|
- rt = ip_route_output(dev_net(dev), iph->daddr, 0,
|
|
|
+ rt = ip_route_output(net, iph->daddr, 0,
|
|
|
RT_TOS(iph->tos), 0);
|
|
|
if (!IS_ERR(rt)) {
|
|
|
/* - Bridged-and-DNAT'ed traffic doesn't
|
|
@@ -393,7 +393,7 @@ bridged_dnat:
|
|
|
nf_bridge_push_encap_header(skb);
|
|
|
NF_HOOK_THRESH(NFPROTO_BRIDGE,
|
|
|
NF_BR_PRE_ROUTING,
|
|
|
- sk, skb, skb->dev, NULL,
|
|
|
+ net, sk, skb, skb->dev, NULL,
|
|
|
br_nf_pre_routing_finish_bridge,
|
|
|
1);
|
|
|
return 0;
|
|
@@ -413,7 +413,7 @@ bridged_dnat:
|
|
|
skb->dev = nf_bridge->physindev;
|
|
|
nf_bridge_update_protocol(skb);
|
|
|
nf_bridge_push_encap_header(skb);
|
|
|
- NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, sk, skb,
|
|
|
+ NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, net, sk, skb,
|
|
|
skb->dev, NULL,
|
|
|
br_handle_frame_finish, 1);
|
|
|
|
|
@@ -511,7 +511,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
|
|
|
|
|
|
skb->protocol = htons(ETH_P_IP);
|
|
|
|
|
|
- NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->sk, skb,
|
|
|
+ NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->net, state->sk, skb,
|
|
|
skb->dev, NULL,
|
|
|
br_nf_pre_routing_finish);
|
|
|
|
|
@@ -535,7 +535,7 @@ static unsigned int br_nf_local_in(const struct nf_hook_ops *ops,
|
|
|
}
|
|
|
|
|
|
/* PF_BRIDGE/FORWARD *************************************************/
|
|
|
-static int br_nf_forward_finish(struct sock *sk, struct sk_buff *skb)
|
|
|
+static int br_nf_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
|
|
{
|
|
|
struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
|
|
|
struct net_device *in;
|
|
@@ -559,7 +559,7 @@ static int br_nf_forward_finish(struct sock *sk, struct sk_buff *skb)
|
|
|
}
|
|
|
nf_bridge_push_encap_header(skb);
|
|
|
|
|
|
- NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_FORWARD, sk, skb,
|
|
|
+ NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_FORWARD, net, sk, skb,
|
|
|
in, skb->dev, br_forward_finish, 1);
|
|
|
return 0;
|
|
|
}
|
|
@@ -626,7 +626,7 @@ static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
|
|
|
else
|
|
|
skb->protocol = htons(ETH_P_IPV6);
|
|
|
|
|
|
- NF_HOOK(pf, NF_INET_FORWARD, NULL, skb,
|
|
|
+ NF_HOOK(pf, NF_INET_FORWARD, state->net, NULL, skb,
|
|
|
brnf_get_logical_dev(skb, state->in),
|
|
|
parent, br_nf_forward_finish);
|
|
|
|
|
@@ -661,14 +661,14 @@ static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops,
|
|
|
return NF_ACCEPT;
|
|
|
}
|
|
|
*d = state->in;
|
|
|
- NF_HOOK(NFPROTO_ARP, NF_ARP_FORWARD, state->sk, skb,
|
|
|
+ NF_HOOK(NFPROTO_ARP, NF_ARP_FORWARD, state->net, state->sk, skb,
|
|
|
state->in, state->out, br_nf_forward_finish);
|
|
|
|
|
|
return NF_STOLEN;
|
|
|
}
|
|
|
|
|
|
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4) || IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
|
|
|
-static int br_nf_push_frag_xmit(struct sock *sk, struct sk_buff *skb)
|
|
|
+static int br_nf_push_frag_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
|
|
|
{
|
|
|
struct brnf_frag_data *data;
|
|
|
int err;
|
|
@@ -690,23 +690,27 @@ static int br_nf_push_frag_xmit(struct sock *sk, struct sk_buff *skb)
|
|
|
__skb_push(skb, data->encap_size);
|
|
|
|
|
|
nf_bridge_info_free(skb);
|
|
|
- return br_dev_queue_push_xmit(sk, skb);
|
|
|
+ return br_dev_queue_push_xmit(net, sk, skb);
|
|
|
+}
|
|
|
+static int br_nf_push_frag_xmit_sk(struct sock *sk, struct sk_buff *skb)
|
|
|
+{
|
|
|
+ struct net *net = dev_net(skb_dst(skb)->dev);
|
|
|
+ return br_nf_push_frag_xmit(net, sk, skb);
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4)
|
|
|
-static int br_nf_ip_fragment(struct sock *sk, struct sk_buff *skb,
|
|
|
- int (*output)(struct sock *, struct sk_buff *))
|
|
|
+static int
|
|
|
+br_nf_ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
|
|
|
+ int (*output)(struct sock *, struct sk_buff *))
|
|
|
{
|
|
|
unsigned int mtu = ip_skb_dst_mtu(skb);
|
|
|
struct iphdr *iph = ip_hdr(skb);
|
|
|
- struct rtable *rt = skb_rtable(skb);
|
|
|
- struct net_device *dev = rt->dst.dev;
|
|
|
|
|
|
if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) ||
|
|
|
(IPCB(skb)->frag_max_size &&
|
|
|
IPCB(skb)->frag_max_size > mtu))) {
|
|
|
- IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
|
|
|
+ IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
|
|
|
kfree_skb(skb);
|
|
|
return -EMSGSIZE;
|
|
|
}
|
|
@@ -722,7 +726,7 @@ static unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
|
|
|
+static int br_nf_dev_queue_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
|
|
|
{
|
|
|
struct nf_bridge_info *nf_bridge;
|
|
|
unsigned int mtu_reserved;
|
|
@@ -731,7 +735,7 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
|
|
|
|
|
|
if (skb_is_gso(skb) || skb->len + mtu_reserved <= skb->dev->mtu) {
|
|
|
nf_bridge_info_free(skb);
|
|
|
- return br_dev_queue_push_xmit(sk, skb);
|
|
|
+ return br_dev_queue_push_xmit(net, sk, skb);
|
|
|
}
|
|
|
|
|
|
nf_bridge = nf_bridge_info_get(skb);
|
|
@@ -760,7 +764,7 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
|
|
|
skb_copy_from_linear_data_offset(skb, -data->size, data->mac,
|
|
|
data->size);
|
|
|
|
|
|
- return br_nf_ip_fragment(sk, skb, br_nf_push_frag_xmit);
|
|
|
+ return br_nf_ip_fragment(net, sk, skb, br_nf_push_frag_xmit_sk);
|
|
|
}
|
|
|
#endif
|
|
|
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
|
|
@@ -783,14 +787,14 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
|
|
|
data->size);
|
|
|
|
|
|
if (v6ops)
|
|
|
- return v6ops->fragment(sk, skb, br_nf_push_frag_xmit);
|
|
|
+ return v6ops->fragment(sk, skb, br_nf_push_frag_xmit_sk);
|
|
|
|
|
|
kfree_skb(skb);
|
|
|
return -EMSGSIZE;
|
|
|
}
|
|
|
#endif
|
|
|
nf_bridge_info_free(skb);
|
|
|
- return br_dev_queue_push_xmit(sk, skb);
|
|
|
+ return br_dev_queue_push_xmit(net, sk, skb);
|
|
|
drop:
|
|
|
kfree_skb(skb);
|
|
|
return 0;
|
|
@@ -836,7 +840,7 @@ static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops,
|
|
|
else
|
|
|
skb->protocol = htons(ETH_P_IPV6);
|
|
|
|
|
|
- NF_HOOK(pf, NF_INET_POST_ROUTING, state->sk, skb,
|
|
|
+ NF_HOOK(pf, NF_INET_POST_ROUTING, state->net, state->sk, skb,
|
|
|
NULL, realoutdev,
|
|
|
br_nf_dev_queue_xmit);
|
|
|
|
|
@@ -880,7 +884,7 @@ static void br_nf_pre_routing_finish_bridge_slow(struct sk_buff *skb)
|
|
|
skb->dev = nf_bridge->physindev;
|
|
|
|
|
|
nf_bridge->physoutdev = NULL;
|
|
|
- br_handle_frame_finish(NULL, skb);
|
|
|
+ br_handle_frame_finish(dev_net(skb->dev), NULL, skb);
|
|
|
}
|
|
|
|
|
|
static int br_nf_dev_xmit(struct sk_buff *skb)
|