From de06e92fc9b22f9c78316a2f2f4bc524696a91f6 Mon Sep 17 00:00:00 2001 From: Serhey Popovych Date: Fri, 29 Nov 2019 11:21:29 +0200 Subject: configure.ac: Build on kernels without skb->vlan_proto correctly Support for EtherType other than ETH_P_8021Q for VLAN header introduced with commit 86a9bad3ab6b ("net: vlan: add protocol argument to packet tagging functions") in upstream kernel since v3.10. To support build on older kernels check for ->vlan_proto presence in @struct sk_buff and return htons(ETH_P_8021Q) when it is missing. Signed-off-by: Serhey Popovych Signed-off-by: Jozsef Kadlecsik --- configure.ac | 11 +++++++++++ kernel/include/linux/netfilter/ipset/ip_set_compat.h.in | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/configure.ac b/configure.ac index ced2880..8fe1890 100644 --- a/configure.ac +++ b/configure.ac @@ -535,6 +535,17 @@ if test -f $ksourcedir/include/net/pkt_sched.h && \ else AC_MSG_RESULT(no) AC_SUBST(HAVE_TC_SKB_PROTOCOL, undef) + + AC_MSG_CHECKING([kernel source for vlan_proto in struct sk_buff]) + if test -f $ksourcedir/include/linux/skbuff.h && \ + $AWK '/^struct sk_buff {/,/^};$/' $ksourcedir/include/linux/skbuff.h | \ + $GREP -q 'vlan_proto'; then + AC_MSG_RESULT(yes) + AC_SUBST(HAVE_VLAN_PROTO_IN_SK_BUFF, define) + else + AC_MSG_RESULT(no) + AC_SUBST(HAVE_VLAN_PROTO_IN_SK_BUFF, undef) + fi fi AC_MSG_CHECKING([kernel source for struct net in struct xt_action_param]) diff --git a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in index f4d7acc..38f4179 100644 --- a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in +++ b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in @@ -338,7 +338,11 @@ static inline int nla_put_in6_addr(struct sk_buff *skb, int attrtype, static inline __be16 tc_skb_protocol(const struct sk_buff *skb) { if (vlan_tx_tag_present(skb)) +#ifdef HAVE_VLAN_PROTO_IN_SK_BUFF return skb->vlan_proto; +#else + return htons(ETH_P_8021Q); +#endif return skb->protocol; } #endif -- cgit v1.2.3