* [PATCH net-next 0/2] Put ip6_fragment in ipv6_stub @ 2020-08-27 10:39 wenxu 2020-08-27 10:39 ` [PATCH net-next 1/2] ipv6: add ipv6_fragment hook " wenxu 2020-08-27 10:39 ` [PATCH net-next 2/2] openvswitch: using ip6_fragment " wenxu 0 siblings, 2 replies; 6+ messages in thread From: wenxu @ 2020-08-27 10:39 UTC (permalink / raw) To: netdev; +Cc: davem, marcelo.leitner From: wenxu <wenxu@ucloud.cn> Add ip6_fragment in ipv6_stub and use it in openvswitch wenxu (2): ipv6: add ipv6_fragment hook in ipv6_stub openvswitch: using ip6_fragment in ipv6_stub include/net/ipv6_stubs.h | 2 ++ net/ipv6/af_inet6.c | 1 + net/openvswitch/actions.c | 6 ++---- 3 files changed, 5 insertions(+), 4 deletions(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/2] ipv6: add ipv6_fragment hook in ipv6_stub 2020-08-27 10:39 [PATCH net-next 0/2] Put ip6_fragment in ipv6_stub wenxu @ 2020-08-27 10:39 ` wenxu 2020-08-27 14:51 ` David Miller 2020-08-27 10:39 ` [PATCH net-next 2/2] openvswitch: using ip6_fragment " wenxu 1 sibling, 1 reply; 6+ messages in thread From: wenxu @ 2020-08-27 10:39 UTC (permalink / raw) To: netdev; +Cc: davem, marcelo.leitner From: wenxu <wenxu@ucloud.cn> Add ipv6_fragment to ipv6_stub to avoid calling netfilter when access ip6_fragment. Signed-off-by: wenxu <wenxu@ucloud.cn> --- include/net/ipv6_stubs.h | 3 +++ net/ipv6/af_inet6.c | 1 + 2 files changed, 4 insertions(+) diff --git a/include/net/ipv6_stubs.h b/include/net/ipv6_stubs.h index d7a7f7c..8fce558 100644 --- a/include/net/ipv6_stubs.h +++ b/include/net/ipv6_stubs.h @@ -63,6 +63,9 @@ struct ipv6_stub { int encap_type); #endif struct neigh_table *nd_tbl; + + int (*ipv6_fragment)(struct net *net, struct sock *sk, struct sk_buff *skb, + int (*output)(struct net *, struct sock *, struct sk_buff *)); }; extern const struct ipv6_stub *ipv6_stub __read_mostly; diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index d9a1493..e648fbe 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -1027,6 +1027,7 @@ static int ipv6_route_input(struct sk_buff *skb) .xfrm6_rcv_encap = xfrm6_rcv_encap, #endif .nd_tbl = &nd_tbl, + .ipv6_fragment = ip6_fragment, }; static const struct ipv6_bpf_stub ipv6_bpf_stub_impl = { -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] ipv6: add ipv6_fragment hook in ipv6_stub 2020-08-27 10:39 ` [PATCH net-next 1/2] ipv6: add ipv6_fragment hook " wenxu @ 2020-08-27 14:51 ` David Miller 2020-08-27 22:38 ` Marcelo Ricardo Leitner 0 siblings, 1 reply; 6+ messages in thread From: David Miller @ 2020-08-27 14:51 UTC (permalink / raw) To: wenxu; +Cc: netdev, marcelo.leitner From: wenxu@ucloud.cn Date: Thu, 27 Aug 2020 18:39:51 +0800 > From: wenxu <wenxu@ucloud.cn> > > Add ipv6_fragment to ipv6_stub to avoid calling netfilter when > access ip6_fragment. > > Signed-off-by: wenxu <wenxu@ucloud.cn> Please test these changes with ipv6 disabled. It will crash, you have to update the default stub in net/ipv6/addrconf_core.c as well. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] ipv6: add ipv6_fragment hook in ipv6_stub 2020-08-27 14:51 ` David Miller @ 2020-08-27 22:38 ` Marcelo Ricardo Leitner 2020-08-27 23:33 ` wenxu 0 siblings, 1 reply; 6+ messages in thread From: Marcelo Ricardo Leitner @ 2020-08-27 22:38 UTC (permalink / raw) To: David Miller; +Cc: wenxu, netdev On Thu, Aug 27, 2020 at 07:51:47AM -0700, David Miller wrote: > From: wenxu@ucloud.cn > Date: Thu, 27 Aug 2020 18:39:51 +0800 > > > From: wenxu <wenxu@ucloud.cn> > > > > Add ipv6_fragment to ipv6_stub to avoid calling netfilter when > > access ip6_fragment. > > > > Signed-off-by: wenxu <wenxu@ucloud.cn> > > Please test these changes with ipv6 disabled. > > It will crash, you have to update the default stub in > net/ipv6/addrconf_core.c as well. I didn't test it myself but I'm not seeing how the crash could happen. The next patch does check for it being NULL before using it: - if (!v6ops) + if (!ipv6_stub->ipv6_fragment) goto err; Wenxu? Marcelo ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] ipv6: add ipv6_fragment hook in ipv6_stub 2020-08-27 22:38 ` Marcelo Ricardo Leitner @ 2020-08-27 23:33 ` wenxu 0 siblings, 0 replies; 6+ messages in thread From: wenxu @ 2020-08-27 23:33 UTC (permalink / raw) To: Marcelo Ricardo Leitner, David Miller; +Cc: netdev Yes, I check the ipv6_stub->ipv6_fragment. And in the case if there is no ipv6_stub->ipv6_fragment it means no ipv6 fragment support and it should free the skb. Maybe sometimes not all the calling remember to check with this? So it should add a default one with following? +static int eafnosupport_ipv6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, + int (*output)(struct net *, struct sock *, struct sk_buff *)) +{ + kfree_skb(skb); + return -EAFNOSUPPORT; +} + 在 2020/8/28 6:38, Marcelo Ricardo Leitner 写道: > On Thu, Aug 27, 2020 at 07:51:47AM -0700, David Miller wrote: >> From: wenxu@ucloud.cn >> Date: Thu, 27 Aug 2020 18:39:51 +0800 >> >>> From: wenxu <wenxu@ucloud.cn> >>> >>> Add ipv6_fragment to ipv6_stub to avoid calling netfilter when >>> access ip6_fragment. >>> >>> Signed-off-by: wenxu <wenxu@ucloud.cn> >> Please test these changes with ipv6 disabled. >> >> It will crash, you have to update the default stub in >> net/ipv6/addrconf_core.c as well. > I didn't test it myself but I'm not seeing how the crash could happen. > The next patch does check for it being NULL before using it: > > - if (!v6ops) > + if (!ipv6_stub->ipv6_fragment) > goto err; > > Wenxu? > > Marcelo > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 2/2] openvswitch: using ip6_fragment in ipv6_stub 2020-08-27 10:39 [PATCH net-next 0/2] Put ip6_fragment in ipv6_stub wenxu 2020-08-27 10:39 ` [PATCH net-next 1/2] ipv6: add ipv6_fragment hook " wenxu @ 2020-08-27 10:39 ` wenxu 1 sibling, 0 replies; 6+ messages in thread From: wenxu @ 2020-08-27 10:39 UTC (permalink / raw) To: netdev; +Cc: davem, marcelo.leitner From: wenxu <wenxu@ucloud.cn> Using ipv6_stub->ipv6_fragment to avoid the netfilter dependency Signed-off-by: wenxu <wenxu@ucloud.cn> --- net/openvswitch/actions.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index 2611657..1f3d406 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -9,7 +9,6 @@ #include <linux/in.h> #include <linux/ip.h> #include <linux/openvswitch.h> -#include <linux/netfilter_ipv6.h> #include <linux/sctp.h> #include <linux/tcp.h> #include <linux/udp.h> @@ -848,11 +847,10 @@ static void ovs_fragment(struct net *net, struct vport *vport, ip_do_fragment(net, skb->sk, skb, ovs_vport_output); refdst_drop(orig_dst); } else if (key->eth.type == htons(ETH_P_IPV6)) { - const struct nf_ipv6_ops *v6ops = nf_get_ipv6_ops(); unsigned long orig_dst; struct rt6_info ovs_rt; - if (!v6ops) + if (!ipv6_stub->ipv6_fragment) goto err; prepare_frag(vport, skb, orig_network_offset, @@ -866,7 +864,7 @@ static void ovs_fragment(struct net *net, struct vport *vport, skb_dst_set_noref(skb, &ovs_rt.dst); IP6CB(skb)->frag_max_size = mru; - v6ops->fragment(net, skb->sk, skb, ovs_vport_output); + ipv6_stub->ipv6_fragment(net, skb->sk, skb, ovs_vport_output); refdst_drop(orig_dst); } else { WARN_ONCE(1, "Failed fragment ->%s: eth=%04x, MRU=%d, MTU=%d.", -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-08-27 23:35 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-08-27 10:39 [PATCH net-next 0/2] Put ip6_fragment in ipv6_stub wenxu 2020-08-27 10:39 ` [PATCH net-next 1/2] ipv6: add ipv6_fragment hook " wenxu 2020-08-27 14:51 ` David Miller 2020-08-27 22:38 ` Marcelo Ricardo Leitner 2020-08-27 23:33 ` wenxu 2020-08-27 10:39 ` [PATCH net-next 2/2] openvswitch: using ip6_fragment " wenxu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox