Skip to content

Commit

Permalink
compat: Detect and use nf_ipv6_ops->fragment.
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Stringer <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
  • Loading branch information
joestringer committed Feb 2, 2016
1 parent ac9cd0d commit e4e04c3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 2 additions & 0 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
OVS_GREP_IFELSE([$KSRC/include/linux/netfilter.h], [nf_register_net_hook])
OVS_GREP_IFELSE([$KSRC/include/linux/netfilter.h], [nf_hookfn.*nf_hook_ops],
[OVS_DEFINE([HAVE_NF_HOOKFN_ARG_OPS])])
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netfilter_ipv6.h], [nf_ipv6_ops],
[fragment], [OVS_DEFINE([HAVE_NF_IPV6_OPS_FRAGMENT])])
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
[tmpl_alloc.*conntrack_zone],
Expand Down
5 changes: 5 additions & 0 deletions datapath/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ static inline bool skb_encapsulation(struct sk_buff *skb)
#endif

#ifdef OVS_FRAGMENT_BACKPORT
#ifdef HAVE_NF_IPV6_OPS_FRAGMENT
static inline int __init ip6_output_init(void) { return 0; }
static inline void ip6_output_exit(void) { }
#else
int __init ip6_output_init(void);
void ip6_output_exit(void);
#endif

static inline int __init compat_init(void)
{
Expand Down
6 changes: 3 additions & 3 deletions datapath/linux/compat/include/linux/netfilter_ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <net/ip.h> /* For OVS_VPORT_OUTPUT_PARAMS */
#include <net/ip6_route.h>

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
#ifndef HAVE_NF_IPV6_OPS_FRAGMENT
/* Try to minimise changes required to the actions.c code for calling IPv6
* fragmentation. We can keep the fragment() API mostly the same, except that
* the callback parameter needs to be in the form that older kernels accept.
Expand All @@ -27,13 +27,13 @@ static inline struct ovs_nf_ipv6_ops *ovs_nf_get_ipv6_ops(void)
{
return &ovs_ipv6_ops;
}
#else /* !OVS_FRAGMENT_BACKPORT || !CONFIG_NETFILTER || || !CONFIG_IPV6 */
#else /* !OVS_FRAGMENT_BACKPORT */
static inline const struct ovs_nf_ipv6_ops *ovs_nf_get_ipv6_ops(void)
{
return NULL;
}
#endif
#define nf_get_ipv6_ops ovs_nf_get_ipv6_ops

#endif /* < 4.3 */
#endif /* HAVE_NF_IPV6_OPS_FRAGMENT */
#endif /* __NETFILTER_IPV6_WRAPPER_H */
13 changes: 7 additions & 6 deletions datapath/linux/compat/include/net/ip6_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ struct dst_entry *rpl_ip6_route_output(struct net *net, const struct sock *sk,

#endif /* 2.6.39 */

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
#ifndef HAVE_NF_IPV6_OPS_FRAGMENT
#ifdef OVS_FRAGMENT_BACKPORT
int rpl_ip6_fragment(struct sock *sk, struct sk_buff *skb,
int (*output)(OVS_VPORT_OUTPUT_PARAMS));
#else
static inline int rpl_ip6_fragment(struct sock *sk, struct sk_buff *skb,
int (*output)(struct sk_buff *))
{
kfree_skb(skb);
return -ENOTSUPP;
}
#define ip6_fragment rpl_ip6_fragment
#elif defined(OVS_FRAGMENT_BACKPORT)
int rpl_ip6_fragment(struct sock *sk, struct sk_buff *skb,
int (*output)(OVS_VPORT_OUTPUT_PARAMS));
#define ip6_fragment rpl_ip6_fragment
#endif /* OVS_FRAGMENT_BACKPORT */
#define ip6_fragment rpl_ip6_fragment
#endif /* HAVE_NF_IPV6_OPS_FRAGMENT */

#endif /* _NET_IP6_ROUTE_WRAPPER */
2 changes: 1 addition & 1 deletion datapath/linux/compat/ip6_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <linux/version.h>

#ifdef OVS_FRAGMENT_BACKPORT
#if !defined(HAVE_NF_IPV6_OPS_FRAGMENT) && defined(OVS_FRAGMENT_BACKPORT)

#include <linux/errno.h>
#include <linux/kernel.h>
Expand Down

0 comments on commit e4e04c3

Please sign in to comment.