| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/07/23 23:37 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": [
"IP_VS",
"IP_VS_IPV6",
"IP_VS_PROTO_TCP",
"IP_VS_PROTO_UDP",
"IP_VS_PROTO_SCTP",
"NF_CONNTRACK_SIP",
"NF_NAT_SIP",
"NF_CONNTRACK_H323",
"NF_NAT_H323",
"NF_TABLES",
"NETFILTER_XT_MATCH_HASHLIMIT"
],
"FocusSymbols": [
"ip_vs_conn_fill_cport",
"ip_vs_conn_change_fwd_mask",
"ip_vs_nat_icmp",
"ip_vs_nat_icmp_v6",
"ip_vs_out_icmp",
"ip_vs_in_icmp",
"ip_vs_icmp_xmit",
"ip_vs_icmp_xmit_v6",
"tcp_csum_check",
"udp_csum_check",
"sctp_csum_check",
"nf_ct_expect_related_pair",
"nat_rtp_rtcp",
"nf_nat_sdp_media",
"nft_obj_lookup",
"nf_tables_newtable",
"nf_tables_newobj",
"nft_obj_del",
"hashlimit_mt_check_common"
],
"Reasoning": "The patch series makes functional changes to multiple core networking and netfilter subsystems, including IPVS connection handling and ICMP/checksum processing, conntrack expectation handling for SIP and H.323, nf_tables object lookup mechanisms, and xt_hashlimit matching. These changes modify reachable kernel logic and should be fuzzed.",
"WorthFuzzing": true
} |
| 1/1 | 2026/07/23 23:37 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 71d4942b84b5b2bf1ac7280cf9e102e20da445f2\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Thu Jul 23 23:37:52 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/include/linux/netfilter/nf_conntrack_sip.h b/include/linux/netfilter/nf_conntrack_sip.h\nindex dbc614dfe0d565..aafa0c04f917eb 100644\n--- a/include/linux/netfilter/nf_conntrack_sip.h\n+++ b/include/linux/netfilter/nf_conntrack_sip.h\n@@ -115,7 +115,7 @@ struct nf_nat_sip_hooks {\n \t\t\t unsigned int *datalen);\n \n \tvoid (*seq_adjust)(struct sk_buff *skb,\n-\t\t\t unsigned int protoff, s16 off);\n+\t\t\t unsigned int protoff, s32 off);\n \n \tunsigned int (*expect)(struct sk_buff *skb,\n \t\t\t unsigned int protoff,\ndiff --git a/include/net/ip_vs.h b/include/net/ip_vs.h\nindex 417ff51f62fc8e..9ae9aad65541d3 100644\n--- a/include/net/ip_vs.h\n+++ b/include/net/ip_vs.h\n@@ -25,7 +25,9 @@\n #include \u003clinux/netfilter.h\u003e\t\t/* for union nf_inet_addr */\n #include \u003clinux/ip.h\u003e\n #include \u003clinux/ipv6.h\u003e\t\t\t/* for struct ipv6hdr */\n+#include \u003cnet/route.h\u003e\n #include \u003cnet/ipv6.h\u003e\n+#include \u003cnet/ip6_fib.h\u003e\n #if IS_ENABLED(CONFIG_NF_CONNTRACK)\n #include \u003cnet/netfilter/nf_conntrack.h\u003e\n #endif\n@@ -1972,8 +1974,8 @@ int ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,\n int ip_vs_dr_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,\n \t\t struct ip_vs_protocol *pp, struct ip_vs_iphdr *iph);\n int ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,\n-\t\t struct ip_vs_protocol *pp, int offset,\n-\t\t unsigned int hooknum, struct ip_vs_iphdr *iph);\n+\t\t struct ip_vs_protocol *pp, unsigned int toff,\n+\t\t unsigned int hooknum, struct ip_vs_iphdr *ciph);\n void ip_vs_dest_dst_rcu_free(struct rcu_head *head);\n \n #ifdef CONFIG_IP_VS_IPV6\n@@ -1986,8 +1988,8 @@ int ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,\n int ip_vs_dr_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,\n \t\t struct ip_vs_protocol *pp, struct ip_vs_iphdr *iph);\n int ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,\n-\t\t struct ip_vs_protocol *pp, int offset,\n-\t\t unsigned int hooknum, struct ip_vs_iphdr *iph);\n+\t\t struct ip_vs_protocol *pp, unsigned int toff,\n+\t\t unsigned int hooknum, struct ip_vs_iphdr *ciph);\n #endif\n \n #ifdef CONFIG_SYSCTL\n@@ -2059,15 +2061,15 @@ static inline bool ip_vs_conn_use_hash2(struct ip_vs_conn *cp)\n }\n \n void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,\n-\t\t struct ip_vs_conn *cp, int dir);\n+\t\t struct ip_vs_conn *cp, int dir, unsigned int toff,\n+\t\t bool has_ports);\n \n #ifdef CONFIG_IP_VS_IPV6\n void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp,\n-\t\t struct ip_vs_conn *cp, int dir);\n+\t\t struct ip_vs_conn *cp, int dir, unsigned int toff,\n+\t\t bool has_ports, struct ip_vs_iphdr *ciph);\n #endif\n \n-__sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset);\n-\n static inline __wsum ip_vs_check_diff4(__be32 old, __be32 new, __wsum oldsum)\n {\n \t__be32 diff[2] = { ~old, new };\n@@ -2093,6 +2095,36 @@ static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum)\n \treturn csum_partial(diff, sizeof(diff), oldsum);\n }\n \n+static inline bool ip_vs_checksum_needed(struct sk_buff *skb, int af)\n+{\n+\t/* Checksum unnecessary or already validated? */\n+\tif (skb_csum_unnecessary(skb))\n+\t\treturn false;\n+\t/* LOCAL_OUT ? */\n+\tif (!skb-\u003edev || skb-\u003edev-\u003eflags \u0026 IFF_LOOPBACK)\n+\t\treturn false;\n+\t/* !LOCAL_IN (FORWARD) ? */\n+\tif (af == AF_INET6) {\n+\t\tif (!(dst_rt6_info(skb_dst(skb))-\u003ert6i_flags \u0026 RTF_LOCAL))\n+\t\t\treturn false;\n+\t} else {\n+\t\tif (!(skb_rtable(skb)-\u003ert_flags \u0026 RTCF_LOCAL))\n+\t\t\treturn false;\n+\t}\n+\treturn true;\n+}\n+\n+/**\n+ * ip_vs_checksum_common_check - validate checksum for TCP/UDP/ICMP\n+ */\n+static inline bool ip_vs_checksum_common_check(struct sk_buff *skb,\n+\t\t\t\t\t int offset, int proto, int af)\n+{\n+\tif (!ip_vs_checksum_needed(skb, af))\n+\t\treturn true;\n+\treturn !nf_checksum(skb, NF_INET_LOCAL_IN, offset, proto, af);\n+}\n+\n /* Forget current conntrack (unconfirmed) and attach notrack entry */\n static inline void ip_vs_notrack(struct sk_buff *skb)\n {\ndiff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h\nindex c024345c9bd862..26d6babd92fcd7 100644\n--- a/include/net/netfilter/nf_conntrack_expect.h\n+++ b/include/net/netfilter/nf_conntrack_expect.h\n@@ -161,6 +161,9 @@ static inline int nf_ct_expect_related(struct nf_conntrack_expect *expect,\n \treturn nf_ct_expect_related_report(expect, 0, 0, flags);\n }\n \n+int nf_ct_expect_related_pair(struct nf_conntrack_expect *expect[],\n+\t\t\t unsigned int flag);\n+\n struct nf_conn_help;\n void nf_ct_expectation_gc(struct nf_conn_help *master_help);\n \ndiff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h\nindex 9d844354c4d956..3be612145c130c 100644\n--- a/include/net/netfilter/nf_tables.h\n+++ b/include/net/netfilter/nf_tables.h\n@@ -1294,6 +1294,7 @@ static inline void nft_use_inc_restore(u32 *use)\n *\t@sets: sets in the table\n *\t@objects: stateful objects in the table\n *\t@flowtables: flow tables in the table\n+ *\t@objname_ht: hashtable for objects lookup by name\n *\t@hgenerator: handle generator state\n *\t@handle: table handle\n *\t@use: number of chain references to this table\n@@ -1313,6 +1314,7 @@ struct nft_table {\n \tstruct list_head\t\tsets;\n \tstruct list_head\t\tobjects;\n \tstruct list_head\t\tflowtables;\n+\tstruct rhltable\t\t\tobjname_ht;\n \tu64\t\t\t\thgenerator;\n \tu64\t\t\t\thandle;\n \tu32\t\t\t\tuse;\n@@ -1400,7 +1402,7 @@ static inline void *nft_obj_data(const struct nft_object *obj)\n #define nft_expr_obj(expr)\t*((struct nft_object **)nft_expr_priv(expr))\n \n struct nft_object *nft_obj_lookup(const struct net *net,\n-\t\t\t\t const struct nft_table *table,\n+\t\t\t\t struct nft_table *table,\n \t\t\t\t const struct nlattr *nla, u32 objtype,\n \t\t\t\t u8 genmask);\n \ndiff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c\nindex 183e8a3ff2babd..6bcd6734769b59 100644\n--- a/net/ipv4/netfilter/nf_nat_h323.c\n+++ b/net/ipv4/netfilter/nf_nat_h323.c\n@@ -182,6 +182,7 @@ static int nat_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,\n \t\t\tstruct nf_conntrack_expect *rtp_exp,\n \t\t\tstruct nf_conntrack_expect *rtcp_exp)\n {\n+\tstruct nf_conntrack_expect *rtp_pair[2] = { rtp_exp, rtcp_exp };\n \tstruct nf_ct_h323_master *info = nfct_help_data(ct);\n \tint dir = CTINFO2DIR(ctinfo);\n \tint i;\n@@ -227,22 +228,13 @@ static int nat_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,\n \t\tint ret;\n \n \t\trtp_exp-\u003etuple.dst.u.udp.port = htons(nated_port);\n-\t\tret = nf_ct_expect_related(rtp_exp, 0);\n+\t\trtcp_exp-\u003etuple.dst.u.udp.port = htons(nated_port + 1);\n+\t\tret = nf_ct_expect_related_pair(rtp_pair, 0);\n \t\tif (ret == 0) {\n-\t\t\trtcp_exp-\u003etuple.dst.u.udp.port =\n-\t\t\t htons(nated_port + 1);\n-\t\t\tret = nf_ct_expect_related(rtcp_exp, 0);\n-\t\t\tif (ret == 0)\n-\t\t\t\tbreak;\n-\t\t\telse if (ret == -EBUSY) {\n-\t\t\t\tnf_ct_unexpect_related(rtp_exp);\n-\t\t\t\tcontinue;\n-\t\t\t} else if (ret \u003c 0) {\n-\t\t\t\tnf_ct_unexpect_related(rtp_exp);\n-\t\t\t\tnated_port = 0;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t} else if (ret != -EBUSY) {\n+\t\t\tbreak;\n+\t\t} else if (ret == -EBUSY) {\n+\t\t\tcontinue;\n+\t\t} else if (ret \u003c 0) {\n \t\t\tnated_port = 0;\n \t\t\tbreak;\n \t\t}\ndiff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h\nindex 8231317b0f1f4b..b2d77973272d25 100644\n--- a/net/netfilter/ipset/ip_set_hash_gen.h\n+++ b/net/netfilter/ipset/ip_set_hash_gen.h\n@@ -1005,7 +1005,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,\n #endif\n \tif (SET_WITH_COUNTER(set))\n \t\tip_set_init_counter(ext_counter(data, set), ext);\n-\tif (SET_WITH_COMMENT(set))\n+\tif (SET_WITH_COMMENT(set) \u0026\u0026 !ext-\u003etarget)\n \t\tip_set_init_comment(set, ext_comment(data, set), ext);\n \tif (SET_WITH_SKBINFO(set))\n \t\tip_set_init_skbinfo(ext_skbinfo(data, set), ext);\ndiff --git a/net/netfilter/ipvs/ip_vs_app.c b/net/netfilter/ipvs/ip_vs_app.c\nindex b0e00be85cb12c..11cbdbaf561daf 100644\n--- a/net/netfilter/ipvs/ip_vs_app.c\n+++ b/net/netfilter/ipvs/ip_vs_app.c\n@@ -367,7 +367,7 @@ static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff *skb,\n \tif (skb_ensure_writable(skb, ipvsh-\u003elen + sizeof(*th)))\n \t\treturn 0;\n \n-\tth = (struct tcphdr *)(skb_network_header(skb) + ipvsh-\u003elen);\n+\tth = (struct tcphdr *)(skb-\u003edata + ipvsh-\u003elen);\n \n \t/*\n \t *\tRemember seq number in case this pkt gets resized\n@@ -443,7 +443,7 @@ static inline int app_tcp_pkt_in(struct ip_vs_conn *cp, struct sk_buff *skb,\n \tif (skb_ensure_writable(skb, ipvsh-\u003elen + sizeof(*th)))\n \t\treturn 0;\n \n-\tth = (struct tcphdr *)(skb_network_header(skb) + ipvsh-\u003elen);\n+\tth = (struct tcphdr *)(skb-\u003edata + ipvsh-\u003elen);\n \n \t/*\n \t *\tRemember seq number in case this pkt gets resized\ndiff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c\nindex 6ed2622363f0d6..36c5cba03f5bca 100644\n--- a/net/netfilter/ipvs/ip_vs_conn.c\n+++ b/net/netfilter/ipvs/ip_vs_conn.c\n@@ -70,25 +70,45 @@ static struct kmem_cache *ip_vs_conn_cachep __read_mostly;\n * bucket or hash table\n * - hash table resize works like rehash but always rehashes into new table\n * - bit lock on bucket serializes all operations that modify the chain\n+ * - on resize, bucket from the old table is locked before bucket from the\n+ * new table\n * - cp-\u003elock protects conn fields like cp-\u003eflags, cp-\u003edest\n */\n \n-/* Lock conn_tab bucket for conn hash/unhash, not for rehash */\n+/**\n+ * conn_tab_lock - Lock conn_tab buckets for conn hash/unhash, not for rehash\n+ * @t:\t\thash table for hn0, new_tbl when new_hash=true\n+ * @t2:\t\thash table for hn1, new_tbl when new_hash2=true\n+ * @cp:\t\tconnection\n+ * @hash_key:\thash key for hn0\n+ * @hash_key2:\thash key for hn1\n+ * @use2:\tusing hn1 (double hashing) based on the forwarding method\n+ * @new_hash:\tmode for hn0, hash node (true) or seek node (false)\n+ * @new_hash2:\tmode for hn1, hash node (true) or seek node (false)\n+ * @head_ret:\treturned head for hn0\n+ * @head2_ret:\treturned head for hn1\n+ *\n+ * We support 3 modes:\n+ * - seek mode for both nodes, used for unhashing\n+ * - hash mode for both nodes, used for hashing\n+ * - seek hn0 and hash hn1, used when forwarding method is changed\n+ */\n static __always_inline void\n-conn_tab_lock(struct ip_vs_rht *t, struct ip_vs_conn *cp, u32 hash_key,\n-\t u32 hash_key2, bool use2, bool new_hash,\n-\t struct hlist_bl_head **head_ret, struct hlist_bl_head **head2_ret)\n+conn_tab_lock(struct ip_vs_rht *t, struct ip_vs_rht *t2, struct ip_vs_conn *cp,\n+\t u32 hash_key, u32 hash_key2, bool use2, bool new_hash,\n+\t bool new_hash2, struct hlist_bl_head **head_ret,\n+\t struct hlist_bl_head **head2_ret)\n {\n \tstruct hlist_bl_head *head, *head2;\n \tu32 hash_key_new, hash_key_new2;\n-\tstruct ip_vs_rht *t2 = t;\n-\tu32 idx, idx2;\n+\tint idx = 0, idx2 = 0;\n+\n+\t/* Advance idx2 when new_hash is not set but hash_key2\n+\t * is for new table\n+\t */\n+\tif (new_hash2 \u0026\u0026 use2 \u0026\u0026 t != t2)\n+\t\tidx2++;\n \n-\tidx = hash_key \u0026 t-\u003emask;\n-\tif (use2)\n-\t\tidx2 = hash_key2 \u0026 t-\u003emask;\n-\telse\n-\t\tidx2 = idx;\n \tif (!new_hash) {\n \t\t/* We need to lock the bucket in the right table */\n \n@@ -100,46 +120,45 @@ conn_tab_lock(struct ip_vs_rht *t, struct ip_vs_conn *cp, u32 hash_key,\n \t\t\t * both nodes in different tables, use idx/idx2\n \t\t\t * for proper lock ordering for heads.\n \t\t\t */\n-\t\t\tidx = hash_key \u0026 t-\u003emask;\n-\t\t\tidx |= IP_VS_RHT_TABLE_ID_MASK;\n-\t\t}\n-\t\tif (use2) {\n-\t\t\tif (!ip_vs_rht_same_table(t2, hash_key2)) {\n-\t\t\t\t/* It is already moved to new table */\n-\t\t\t\tt2 = rcu_dereference(t2-\u003enew_tbl);\n-\t\t\t\tidx2 = hash_key2 \u0026 t2-\u003emask;\n-\t\t\t\tidx2 |= IP_VS_RHT_TABLE_ID_MASK;\n-\t\t\t}\n-\t\t} else {\n-\t\t\tidx2 = idx;\n+\t\t\tidx++;\n \t\t}\n \t}\n+\tif (use2 \u0026\u0026 !new_hash2 \u0026\u0026 !ip_vs_rht_same_table(t2, hash_key2)) {\n+\t\t/* It is already moved to new table */\n+\t\tt2 = rcu_dereference(t2-\u003enew_tbl);\n+\t\tidx2++;\n+\t}\n \n+\tif (!use2)\n+\t\tidx2 = idx;\n \thead = t-\u003ebuckets + (hash_key \u0026 t-\u003emask);\n \thead2 = use2 ? t2-\u003ebuckets + (hash_key2 \u0026 t2-\u003emask) : head;\n \n-\tlocal_bh_disable();\n-\t/* Do not touch seqcount, this is a safe operation */\n-\n-\tif (idx \u003c= idx2) {\n+\tif (idx \u003e idx2 || (head \u003e head2 \u0026\u0026 idx == idx2)) {\n+\t\thlist_bl_lock(head2);\n \t\thlist_bl_lock(head);\n-\t\tif (head != head2)\n-\t\t\thlist_bl_lock(head2);\n \t} else {\n-\t\thlist_bl_lock(head2);\n \t\thlist_bl_lock(head);\n+\t\tif (head != head2)\n+\t\t\thlist_bl_lock(head2);\n \t}\n \tif (!new_hash) {\n+\t\tbool changed;\n+\n \t\t/* Ensure hash_key is read under lock */\n \t\thash_key_new = READ_ONCE(cp-\u003ehn0.hash_key);\n-\t\thash_key_new2 = READ_ONCE(cp-\u003ehn1.hash_key);\n+\t\tchanged = hash_key != hash_key_new;\n+\t\tif (use2 \u0026\u0026 !new_hash2) {\n+\t\t\thash_key_new2 = READ_ONCE(cp-\u003ehn1.hash_key);\n+\t\t\tchanged |= hash_key2 != hash_key_new2;\n+\t\t} else {\n+\t\t\thash_key_new2 = hash_key2;\n+\t\t}\n \t\t/* Hash changed ? */\n-\t\tif (hash_key != hash_key_new ||\n-\t\t (hash_key2 != hash_key_new2 \u0026\u0026 use2)) {\n+\t\tif (changed) {\n \t\t\tif (head != head2)\n \t\t\t\thlist_bl_unlock(head2);\n \t\t\thlist_bl_unlock(head);\n-\t\t\tlocal_bh_enable();\n \t\t\thash_key = hash_key_new;\n \t\t\thash_key2 = hash_key_new2;\n \t\t\tgoto retry;\n@@ -155,7 +174,6 @@ static inline void conn_tab_unlock(struct hlist_bl_head *head,\n \tif (head != head2)\n \t\thlist_bl_unlock(head2);\n \thlist_bl_unlock(head);\n-\tlocal_bh_enable();\n }\n \n static void ip_vs_conn_expire(struct timer_list *t);\n@@ -268,8 +286,9 @@ static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)\n \t\tuse2 = false;\n \t}\n \n-\tconn_tab_lock(t, cp, hash_key, hash_key2, use2, true /* new_hash */,\n-\t\t \u0026head, \u0026head2);\n+\tlocal_bh_disable();\n+\tconn_tab_lock(t, t, cp, hash_key, hash_key2, use2, true /* new_hash */,\n+\t\t true /* new_hash2 */, \u0026head, \u0026head2);\n \n \tcp-\u003eflags |= IP_VS_CONN_F_HASHED;\n \tWRITE_ONCE(cp-\u003ehn0.hash_key, hash_key);\n@@ -280,6 +299,7 @@ static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)\n \t\thlist_bl_add_head_rcu(\u0026cp-\u003ehn1.node, head2);\n \n \tconn_tab_unlock(head, head2);\n+\tlocal_bh_enable();\n \tret = 1;\n \n \t/* Schedule resizing if load increases */\n@@ -306,18 +326,20 @@ static inline bool ip_vs_conn_unlink(struct ip_vs_conn *cp)\n \t\treturn refcount_dec_if_one(\u0026cp-\u003erefcnt);\n \n \trcu_read_lock();\n+\tlocal_bh_disable();\n \n \tt = rcu_dereference(ipvs-\u003econn_tab);\n \thash_key = READ_ONCE(cp-\u003ehn0.hash_key);\n \thash_key2 = READ_ONCE(cp-\u003ehn1.hash_key);\n \tuse2 = ip_vs_conn_use_hash2(cp);\n \n-\tconn_tab_lock(t, cp, hash_key, hash_key2, use2, false /* new_hash */,\n-\t\t \u0026head, \u0026head2);\n+\tconn_tab_lock(t, t, cp, hash_key, hash_key2, use2, false /* new_hash */,\n+\t\t false /* new_hash2 */, \u0026head, \u0026head2);\n \n \tif (cp-\u003eflags \u0026 IP_VS_CONN_F_HASHED) {\n \t\t/* Decrease refcnt and unlink conn only if we are last user */\n-\t\tif (refcount_dec_if_one(\u0026cp-\u003erefcnt)) {\n+\t\tif (use2 == ip_vs_conn_use_hash2(cp) \u0026\u0026\n+\t\t refcount_dec_if_one(\u0026cp-\u003erefcnt)) {\n \t\t\thlist_bl_del_rcu(\u0026cp-\u003ehn0.node);\n \t\t\tif (use2)\n \t\t\t\thlist_bl_del_rcu(\u0026cp-\u003ehn1.node);\n@@ -328,6 +350,7 @@ static inline bool ip_vs_conn_unlink(struct ip_vs_conn *cp)\n \n \tconn_tab_unlock(head, head2);\n \n+\tlocal_bh_enable();\n \trcu_read_unlock();\n \n \treturn ret;\n@@ -632,6 +655,7 @@ void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport)\n \tint ntbl;\n \tint dir;\n \n+restart:\n \t/* No packets from inside, so we can do it in 2 steps. */\n \tdir = use2 ? 1 : 0;\n \n@@ -686,6 +710,23 @@ void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport)\n \t/* Protect the cp-\u003eflags modification */\n \tspin_lock_bh(\u0026cp-\u003elock);\n \n+\t/* Recheck the forwarding method under lock */\n+\tif (use2 != ip_vs_conn_use_hash2(cp)) {\n+\t\tuse2 = !use2;\n+\t\tif (use2) {\n+\t\t\tspin_unlock_bh(\u0026cp-\u003elock);\n+\t\t\t/* Restart with new use2 value */\n+\t\t\tgoto restart;\n+\t\t}\n+\t\tif (dir) {\n+\t\t\t/* Not started yet, so just skip dir 1 */\n+\t\t\tspin_unlock_bh(\u0026cp-\u003elock);\n+\t\t\tdir--;\n+\t\t\tgoto next_dir;\n+\t\t}\n+\t\t/* Just finish dir 0 */\n+\t}\n+\n \t/* Lock seqcount only for the old bucket, even if we are on new table\n \t * because it affects the del operation, not the adding.\n \t */\n@@ -752,6 +793,61 @@ void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport)\n \t\tgoto next_dir;\n }\n \n+/* Change forwarding method for hashed conn */\n+static void ip_vs_conn_change_fwd_mask(struct ip_vs_conn *cp, u32 new_flags)\n+{\n+\tstruct netns_ipvs *ipvs = cp-\u003eipvs;\n+\tstruct hlist_bl_head *head, *head2;\n+\tu32 hash2, hash_key, hash_key2;\n+\tstruct ip_vs_rht *t, *t2;\n+\n+\t/* See ip_vs_conn_use_hash2() for reference */\n+\tif ((cp-\u003eflags \u0026 IP_VS_CONN_F_TEMPLATE) ||\n+\t /* No change in double hashing ? */\n+\t (IP_VS_FWD_METHOD(cp) == IP_VS_CONN_F_MASQ) ==\n+\t ((new_flags \u0026 IP_VS_CONN_F_FWD_MASK) == IP_VS_CONN_F_MASQ)) {\n+\t\tcp-\u003eflags = new_flags;\n+\t\treturn;\n+\t}\n+\tt = rcu_dereference(ipvs-\u003econn_tab);\n+\tif (ip_vs_conn_use_hash2(cp)) {\n+\t\t/* Stop double hashing */\n+\t\thash_key = READ_ONCE(cp-\u003ehn0.hash_key);\n+\t\thash_key2 = READ_ONCE(cp-\u003ehn1.hash_key);\n+\n+\t\tconn_tab_lock(t, t, cp, hash_key, hash_key2, true /* use2 */,\n+\t\t\t false /* new_hash */, false /* new_hash2 */,\n+\t\t\t \u0026head, \u0026head2);\n+\n+\t\t/* Keep both hash keys in same table */\n+\t\thash_key = READ_ONCE(cp-\u003ehn0.hash_key);\n+\t\tWRITE_ONCE(cp-\u003ehn1.hash_key, hash_key);\n+\t\thlist_bl_del_rcu(\u0026cp-\u003ehn1.node);\n+\t\tcp-\u003eflags = new_flags;\n+\n+\t\tconn_tab_unlock(head, head2);\n+\t} else {\n+\t\t/* Start double hashing */\n+\n+\t\thash_key = READ_ONCE(cp-\u003ehn0.hash_key);\n+\n+\t\tt2 = rcu_dereference(t-\u003enew_tbl);\n+\t\thash2 = ip_vs_conn_hashkey_conn(t2, cp, true);\n+\t\thash_key2 = ip_vs_rht_build_hash_key(t2, hash2);\n+\n+\t\t/* Change the forwarding method under locked hn0 */\n+\t\tconn_tab_lock(t, t2, cp, hash_key, hash_key2, true /* use2 */,\n+\t\t\t false /* new_hash */, true /* new_hash2 */,\n+\t\t\t \u0026head, \u0026head2);\n+\n+\t\tWRITE_ONCE(cp-\u003ehn1.hash_key, hash_key2);\n+\t\tcp-\u003eflags = new_flags;\n+\t\thlist_bl_add_head_rcu(\u0026cp-\u003ehn1.node, head2);\n+\n+\t\tconn_tab_unlock(head, head2);\n+\t}\n+}\n+\n /* Get default load factor to map conn_count/u_thresh to t-\u003esize */\n static int ip_vs_conn_default_load_factor(struct netns_ipvs *ipvs)\n {\n@@ -1014,6 +1110,9 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)\n \tflags = cp-\u003eflags;\n \t/* Bind with the destination and its corresponding transmitter */\n \tif (flags \u0026 IP_VS_CONN_F_SYNC) {\n+\t\t/* Synced conns are hashed, so they can not get this flag */\n+\t\tconn_flags \u0026= ~IP_VS_CONN_F_ONE_PACKET;\n+\n \t\t/* if the connection is not template and is created\n \t\t * by sync, preserve the activity flag.\n \t\t */\n@@ -1021,9 +1120,18 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)\n \t\t\tconn_flags \u0026= ~IP_VS_CONN_F_INACTIVE;\n \t\t/* connections inherit forwarding method from dest */\n \t\tflags \u0026= ~(IP_VS_CONN_F_FWD_MASK | IP_VS_CONN_F_NOOUTPUT);\n+\t\tflags |= conn_flags;\n+\t\t/* Changing forwarding method for hashed conn can\n+\t\t * happen only under locks\n+\t\t */\n+\t\tif (cp-\u003eflags \u0026 IP_VS_CONN_F_HASHED)\n+\t\t\tip_vs_conn_change_fwd_mask(cp, flags);\n+\t\telse\n+\t\t\tcp-\u003eflags = flags;\n+\t} else {\n+\t\tflags |= conn_flags;\n+\t\tcp-\u003eflags = flags;\n \t}\n-\tflags |= conn_flags;\n-\tcp-\u003eflags = flags;\n \tcp-\u003edest = dest;\n \n \tIP_VS_DBG_BUF(7, \"Bind-dest %s c:%s:%d v:%s:%d \"\ndiff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c\nindex bafab93451d037..6b79e0c4d9e284 100644\n--- a/net/netfilter/ipvs/ip_vs_core.c\n+++ b/net/netfilter/ipvs/ip_vs_core.c\n@@ -867,7 +867,7 @@ static int sysctl_nat_icmp_send(struct netns_ipvs *ipvs) { return 0; }\n \n #endif\n \n-__sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset)\n+static __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset)\n {\n \treturn csum_fold(skb_checksum(skb, offset, skb-\u003elen - offset, 0));\n }\n@@ -924,13 +924,13 @@ static int ip_vs_route_me_harder(struct netns_ipvs *ipvs, int af,\n * - inout: 1=in-\u003eout, 0=out-\u003ein\n */\n void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,\n-\t\t struct ip_vs_conn *cp, int inout)\n+\t\t struct ip_vs_conn *cp, int inout, unsigned int toff,\n+\t\t bool has_ports)\n {\n \tstruct iphdr *iph\t = ip_hdr(skb);\n-\tunsigned int icmp_offset = iph-\u003eihl*4;\n-\tstruct icmphdr *icmph\t = (struct icmphdr *)(skb_network_header(skb) +\n-\t\t\t\t\t\t icmp_offset);\n+\tstruct icmphdr *icmph\t = (struct icmphdr *)(skb-\u003edata + toff);\n \tstruct iphdr *ciph\t = (struct iphdr *)(icmph + 1);\n+\tunsigned int coff __maybe_unused = toff + sizeof(struct icmphdr);\n \n \tif (inout) {\n \t\tiph-\u003esaddr = cp-\u003evaddr.ip;\n@@ -945,8 +945,7 @@ void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t}\n \n \t/* the TCP/UDP/SCTP port */\n-\tif (IPPROTO_TCP == ciph-\u003eprotocol || IPPROTO_UDP == ciph-\u003eprotocol ||\n-\t IPPROTO_SCTP == ciph-\u003eprotocol) {\n+\tif (has_ports) {\n \t\t__be16 *ports = (void *)ciph + ciph-\u003eihl*4;\n \n \t\tif (inout)\n@@ -957,48 +956,40 @@ void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \n \t/* And finally the ICMP checksum */\n \ticmph-\u003echecksum = 0;\n-\ticmph-\u003echecksum = ip_vs_checksum_complete(skb, icmp_offset);\n+\ticmph-\u003echecksum = ip_vs_checksum_complete(skb, toff);\n \tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n \n \tif (inout)\n-\t\tIP_VS_DBG_PKT(11, AF_INET, pp, skb, (void *)ciph - (void *)iph,\n-\t\t\t\"Forwarding altered outgoing ICMP\");\n+\t\tIP_VS_DBG_PKT(11, AF_INET, pp, skb, coff,\n+\t\t\t \"Forwarding altered outgoing ICMP\");\n \telse\n-\t\tIP_VS_DBG_PKT(11, AF_INET, pp, skb, (void *)ciph - (void *)iph,\n-\t\t\t\"Forwarding altered incoming ICMP\");\n+\t\tIP_VS_DBG_PKT(11, AF_INET, pp, skb, coff,\n+\t\t\t \"Forwarding altered incoming ICMP\");\n }\n \n #ifdef CONFIG_IP_VS_IPV6\n void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp,\n-\t\t struct ip_vs_conn *cp, int inout)\n+\t\t struct ip_vs_conn *cp, int inout, unsigned int toff,\n+\t\t bool has_ports, struct ip_vs_iphdr *ciph)\n {\n \tstruct ipv6hdr *iph\t = ipv6_hdr(skb);\n-\tunsigned int icmp_offset = 0;\n-\tunsigned int offs\t = 0; /* header offset*/\n-\tint protocol;\n \tstruct icmp6hdr *icmph;\n-\tstruct ipv6hdr *ciph;\n-\tunsigned short fragoffs;\n+\tstruct ipv6hdr *cih;\n \n-\tipv6_find_hdr(skb, \u0026icmp_offset, IPPROTO_ICMPV6, \u0026fragoffs, NULL);\n-\ticmph = (struct icmp6hdr *)(skb_network_header(skb) + icmp_offset);\n-\toffs = icmp_offset + sizeof(struct icmp6hdr);\n-\tciph = (struct ipv6hdr *)(skb_network_header(skb) + offs);\n-\n-\tprotocol = ipv6_find_hdr(skb, \u0026offs, -1, \u0026fragoffs, NULL);\n+\ticmph = (struct icmp6hdr *)(skb-\u003edata + toff);\n+\tcih = (struct ipv6hdr *)(skb-\u003edata + ciph-\u003eoff);\n \n \tif (inout) {\n \t\tiph-\u003esaddr = cp-\u003evaddr.in6;\n-\t\tciph-\u003edaddr = cp-\u003evaddr.in6;\n+\t\tcih-\u003edaddr = cp-\u003evaddr.in6;\n \t} else {\n \t\tiph-\u003edaddr = cp-\u003edaddr.in6;\n-\t\tciph-\u003esaddr = cp-\u003edaddr.in6;\n+\t\tcih-\u003esaddr = cp-\u003edaddr.in6;\n \t}\n \n \t/* the TCP/UDP/SCTP port */\n-\tif (!fragoffs \u0026\u0026 (IPPROTO_TCP == protocol || IPPROTO_UDP == protocol ||\n-\t\t\t IPPROTO_SCTP == protocol)) {\n-\t\t__be16 *ports = (void *)(skb_network_header(skb) + offs);\n+\tif (has_ports) {\n+\t\t__be16 *ports = (void *)(skb-\u003edata + ciph-\u003elen);\n \n \t\tIP_VS_DBG(11, \"%s() changed port %d to %d\\n\", __func__,\n \t\t\t ntohs(inout ? ports[1] : ports[0]),\n@@ -1011,19 +1002,17 @@ void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \n \t/* And finally the ICMP checksum */\n \ticmph-\u003eicmp6_cksum = ~csum_ipv6_magic(\u0026iph-\u003esaddr, \u0026iph-\u003edaddr,\n-\t\t\t\t\t skb-\u003elen - icmp_offset,\n+\t\t\t\t\t skb-\u003elen - toff,\n \t\t\t\t\t IPPROTO_ICMPV6, 0);\n-\tskb-\u003ecsum_start = skb_network_header(skb) - skb-\u003ehead + icmp_offset;\n+\tskb-\u003ecsum_start = skb_headroom(skb) + toff;\n \tskb-\u003ecsum_offset = offsetof(struct icmp6hdr, icmp6_cksum);\n \tskb-\u003eip_summed = CHECKSUM_PARTIAL;\n \n \tif (inout)\n-\t\tIP_VS_DBG_PKT(11, AF_INET6, pp, skb,\n-\t\t\t (void *)ciph - (void *)iph,\n+\t\tIP_VS_DBG_PKT(11, AF_INET6, pp, skb, ciph-\u003eoff,\n \t\t\t \"Forwarding altered outgoing ICMPv6\");\n \telse\n-\t\tIP_VS_DBG_PKT(11, AF_INET6, pp, skb,\n-\t\t\t (void *)ciph - (void *)iph,\n+\t\tIP_VS_DBG_PKT(11, AF_INET6, pp, skb, ciph-\u003eoff,\n \t\t\t \"Forwarding altered incoming ICMPv6\");\n }\n #endif\n@@ -1033,36 +1022,41 @@ void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp,\n */\n static int handle_response_icmp(int af, struct sk_buff *skb,\n \t\t\t\tunion nf_inet_addr *snet,\n-\t\t\t\t__u8 protocol, struct ip_vs_conn *cp,\n+\t\t\t\tstruct ip_vs_conn *cp,\n \t\t\t\tstruct ip_vs_protocol *pp,\n-\t\t\t\tunsigned int offset, unsigned int ihl,\n-\t\t\t\tunsigned int hooknum)\n+\t\t\t\tstruct ip_vs_iphdr *ciph,\n+\t\t\t\tunsigned int toff, unsigned int hooknum)\n {\n+\tint iproto = af == AF_INET6 ? IPPROTO_ICMPV6 : IPPROTO_ICMP;\n \tunsigned int verdict = NF_DROP;\n+\tunsigned int ctoff = ciph-\u003elen;\n+\tbool has_ports = false;\n \n \tif (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)\n \t\tgoto after_nat;\n \n \t/* Ensure the checksum is correct */\n-\tif (!skb_csum_unnecessary(skb) \u0026\u0026 ip_vs_checksum_complete(skb, ihl)) {\n+\tif (!ip_vs_checksum_common_check(skb, toff, iproto, af)) {\n \t\t/* Failed checksum! */\n \t\tIP_VS_DBG_BUF(1, \"Forward ICMP: failed checksum from %s!\\n\",\n \t\t\t IP_VS_DBG_ADDR(af, snet));\n \t\tgoto out;\n \t}\n \n-\tif (IPPROTO_TCP == protocol || IPPROTO_UDP == protocol ||\n-\t IPPROTO_SCTP == protocol)\n-\t\toffset += 2 * sizeof(__u16);\n-\tif (skb_ensure_writable(skb, offset))\n+\tif (ciph-\u003eprotocol == IPPROTO_TCP || ciph-\u003eprotocol == IPPROTO_UDP ||\n+\t ciph-\u003eprotocol == IPPROTO_SCTP) {\n+\t\tctoff += 2 * sizeof(__u16);\n+\t\thas_ports = true;\n+\t}\n+\tif (skb_ensure_writable(skb, ctoff))\n \t\tgoto out;\n \n #ifdef CONFIG_IP_VS_IPV6\n \tif (af == AF_INET6)\n-\t\tip_vs_nat_icmp_v6(skb, pp, cp, 1);\n+\t\tip_vs_nat_icmp_v6(skb, pp, cp, 1, toff, has_ports, ciph);\n \telse\n #endif\n-\t\tip_vs_nat_icmp(skb, pp, cp, 1);\n+\t\tip_vs_nat_icmp(skb, pp, cp, 1, toff, has_ports);\n \n \tif (ip_vs_route_me_harder(cp-\u003eipvs, af, skb, hooknum))\n \t\tgoto out;\n@@ -1090,9 +1084,9 @@ static int handle_response_icmp(int af, struct sk_buff *skb,\n *\tCurrently handles error types - unreachable, quench, ttl exceeded.\n */\n static int ip_vs_out_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb,\n-\t\t\t int *related, unsigned int hooknum)\n+\t\t\t int *related, unsigned int hooknum,\n+\t\t\t struct ip_vs_iphdr *ipvsh)\n {\n-\tstruct iphdr *iph;\n \tstruct icmphdr\t_icmph, *ic;\n \tstruct iphdr\t_ciph, *cih;\t/* The ip header contained within the ICMP */\n \tstruct ip_vs_iphdr ciph;\n@@ -1107,17 +1101,19 @@ static int ip_vs_out_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb,\n \tif (ip_is_fragment(ip_hdr(skb))) {\n \t\tif (ip_vs_gather_frags(ipvs, skb, ip_vs_defrag_user(hooknum)))\n \t\t\treturn NF_STOLEN;\n+\t\tif (!ip_vs_fill_iph_skb(AF_INET, skb, false, ipvsh))\n+\t\t\treturn NF_ACCEPT;\n \t}\n \n-\tiph = ip_hdr(skb);\n-\toffset = ihl = iph-\u003eihl * 4;\n+\tihl = ipvsh-\u003elen;\n+\toffset = ipvsh-\u003elen;\n \tic = skb_header_pointer(skb, offset, sizeof(_icmph), \u0026_icmph);\n \tif (ic == NULL)\n \t\treturn NF_DROP;\n \n \tIP_VS_DBG(12, \"Outgoing ICMP (%d,%d) %pI4-\u003e%pI4\\n\",\n \t\t ic-\u003etype, ntohs(icmp_id(ic)),\n-\t\t \u0026iph-\u003esaddr, \u0026iph-\u003edaddr);\n+\t\t \u0026ipvsh-\u003esaddr.ip, \u0026ipvsh-\u003edaddr.ip);\n \n \t/*\n \t * Work through seeing if this is for us.\n@@ -1136,7 +1132,7 @@ static int ip_vs_out_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb,\n \t/* Now find the contained IP header */\n \toffset += sizeof(_icmph);\n \tcih = skb_header_pointer(skb, offset, sizeof(_ciph), \u0026_ciph);\n-\tif (cih == NULL)\n+\tif (!(cih \u0026\u0026 cih-\u003eversion == 4 \u0026\u0026 cih-\u003eihl \u003e= 5))\n \t\treturn NF_ACCEPT; /* The packet looks wrong, ignore */\n \n \tpp = ip_vs_proto_get(cih-\u003eprotocol);\n@@ -1144,8 +1140,7 @@ static int ip_vs_out_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb,\n \t\treturn NF_ACCEPT;\n \n \t/* Is the embedded protocol header present? */\n-\tif (unlikely(cih-\u003efrag_off \u0026 htons(IP_OFFSET) \u0026\u0026\n-\t\t pp-\u003edont_defrag))\n+\tif (unlikely(cih-\u003efrag_off \u0026 htons(IP_OFFSET) \u0026\u0026 !pp-\u003edont_defrag))\n \t\treturn NF_ACCEPT;\n \n \tIP_VS_DBG_PKT(11, AF_INET, pp, skb, offset,\n@@ -1159,9 +1154,9 @@ static int ip_vs_out_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb,\n \tif (!cp)\n \t\treturn NF_ACCEPT;\n \n-\tsnet.ip = iph-\u003esaddr;\n-\treturn handle_response_icmp(AF_INET, skb, \u0026snet, cih-\u003eprotocol, cp,\n-\t\t\t\t pp, ciph.len, ihl, hooknum);\n+\tsnet.ip = ipvsh-\u003esaddr.ip;\n+\treturn handle_response_icmp(AF_INET, skb, \u0026snet, cp, pp, \u0026ciph, ihl,\n+\t\t\t\t hooknum);\n }\n \n #ifdef CONFIG_IP_VS_IPV6\n@@ -1174,7 +1169,6 @@ static int ip_vs_out_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,\n \tstruct ip_vs_conn *cp;\n \tstruct ip_vs_protocol *pp;\n \tunion nf_inet_addr snet;\n-\tunsigned int offset;\n \n \t*related = 1;\n \tic = frag_safe_skb_hp(skb, ipvsh-\u003elen, sizeof(_icmph), \u0026_icmph);\n@@ -1210,6 +1204,10 @@ static int ip_vs_out_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,\n \tif (!pp)\n \t\treturn NF_ACCEPT;\n \n+\t/* Is the embedded protocol header present? */\n+\tif (unlikely(ciph.fragoffs \u0026\u0026 !pp-\u003edont_defrag))\n+\t\treturn NF_ACCEPT;\n+\n \t/* The embedded headers contain source and dest in reverse order */\n \tcp = INDIRECT_CALL_1(pp-\u003econn_out_get, ip_vs_conn_out_get_proto,\n \t\t\t ipvs, AF_INET6, skb, \u0026ciph);\n@@ -1217,9 +1215,8 @@ static int ip_vs_out_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,\n \t\treturn NF_ACCEPT;\n \n \tsnet.in6 = ciph.saddr.in6;\n-\toffset = ciph.len;\n-\treturn handle_response_icmp(AF_INET6, skb, \u0026snet, ciph.protocol, cp,\n-\t\t\t\t pp, offset, ipvsh-\u003elen, hooknum);\n+\treturn handle_response_icmp(AF_INET6, skb, \u0026snet, cp, pp, \u0026ciph,\n+\t\t\t\t ipvsh-\u003elen, hooknum);\n }\n #endif\n \n@@ -1545,7 +1542,8 @@ ip_vs_out_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *stat\n #endif\n \t\tif (unlikely(iph.protocol == IPPROTO_ICMP)) {\n \t\t\tint related;\n-\t\t\tint verdict = ip_vs_out_icmp(ipvs, skb, \u0026related, hooknum);\n+\t\t\tint verdict = ip_vs_out_icmp(ipvs, skb, \u0026related,\n+\t\t\t\t\t\t hooknum, \u0026iph);\n \n \t\t\tif (related)\n \t\t\t\treturn verdict;\n@@ -1753,9 +1751,8 @@ static int ipvs_gre_decap(struct netns_ipvs *ipvs, struct sk_buff *skb,\n */\n static int\n ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,\n-\t unsigned int hooknum)\n+\t unsigned int hooknum, struct ip_vs_iphdr *iph)\n {\n-\tstruct iphdr *iph;\n \tstruct icmphdr\t_icmph, *ic;\n \tstruct iphdr\t_ciph, *cih;\t/* The ip header contained within the ICMP */\n \tstruct ip_vs_iphdr ciph;\n@@ -1765,7 +1762,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,\n \tunsigned int offset, offset2, ihl, verdict;\n \tbool tunnel, new_cp = false;\n \tunion nf_inet_addr *raddr;\n-\tchar *outer_proto = \"IPIP\";\n+\tchar *outer_proto __maybe_unused = \"IPIP\";\n \tunsigned int hlen_ipip;\n \tint ulen = 0;\n \n@@ -1775,17 +1772,19 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,\n \tif (ip_is_fragment(ip_hdr(skb))) {\n \t\tif (ip_vs_gather_frags(ipvs, skb, ip_vs_defrag_user(hooknum)))\n \t\t\treturn NF_STOLEN;\n+\t\tif (!ip_vs_fill_iph_skb(AF_INET, skb, false, iph))\n+\t\t\treturn NF_ACCEPT;\n \t}\n \n-\tiph = ip_hdr(skb);\n-\toffset = ihl = iph-\u003eihl * 4;\n+\tihl = iph-\u003elen;\n+\toffset = iph-\u003elen;\n \tic = skb_header_pointer(skb, offset, sizeof(_icmph), \u0026_icmph);\n \tif (ic == NULL)\n \t\treturn NF_DROP;\n \n \tIP_VS_DBG(12, \"Incoming ICMP (%d,%d) %pI4-\u003e%pI4\\n\",\n \t\t ic-\u003etype, ntohs(icmp_id(ic)),\n-\t\t \u0026iph-\u003esaddr, \u0026iph-\u003edaddr);\n+\t\t \u0026iph-\u003esaddr.ip, \u0026iph-\u003edaddr.ip);\n \n \t/*\n \t * Work through seeing if this is for us.\n@@ -1867,8 +1866,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,\n \tpp = pd-\u003epp;\n \n \t/* Is the embedded protocol header present? */\n-\tif (unlikely(cih-\u003efrag_off \u0026 htons(IP_OFFSET) \u0026\u0026\n-\t\t pp-\u003edont_defrag))\n+\tif (unlikely(cih-\u003efrag_off \u0026 htons(IP_OFFSET) \u0026\u0026 !pp-\u003edont_defrag))\n \t\treturn NF_ACCEPT;\n \n \tIP_VS_DBG_PKT(11, AF_INET, pp, skb, offset,\n@@ -1876,7 +1874,6 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,\n \n \toffset2 = offset;\n \tip_vs_fill_iph_skb_icmp(AF_INET, skb, offset, !tunnel, \u0026ciph);\n-\toffset = ciph.len;\n \n \t/* The embedded headers contain source and dest in reverse order.\n \t * For IPIP/UDP/GRE tunnel this is error for request, not for reply.\n@@ -1898,10 +1895,11 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,\n \tverdict = NF_DROP;\n \n \t/* Ensure the checksum is correct */\n-\tif (!skb_csum_unnecessary(skb) \u0026\u0026 ip_vs_checksum_complete(skb, ihl)) {\n+\tif ((IP_VS_FWD_METHOD(cp) == IP_VS_CONN_F_MASQ || tunnel) \u0026\u0026\n+\t !ip_vs_checksum_common_check(skb, ihl, IPPROTO_ICMP, AF_INET)) {\n \t\t/* Failed checksum! */\n \t\tIP_VS_DBG(1, \"Incoming ICMP: failed checksum from %pI4!\\n\",\n-\t\t\t \u0026iph-\u003esaddr);\n+\t\t\t \u0026iph-\u003esaddr.ip);\n \t\tgoto out;\n \t}\n \n@@ -1969,10 +1967,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,\n \n \t/* do the statistics and put it back */\n \tip_vs_in_stats(cp, skb);\n-\tif (IPPROTO_TCP == cih-\u003eprotocol || IPPROTO_UDP == cih-\u003eprotocol ||\n-\t IPPROTO_SCTP == cih-\u003eprotocol)\n-\t\toffset += 2 * sizeof(__u16);\n-\tverdict = ip_vs_icmp_xmit(skb, cp, pp, offset, hooknum, \u0026ciph);\n+\tverdict = ip_vs_icmp_xmit(skb, cp, pp, iph-\u003elen, hooknum, \u0026ciph);\n \n out:\n \tif (likely(!new_cp))\n@@ -2032,8 +2027,8 @@ static int ip_vs_in_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,\n \t\treturn NF_ACCEPT;\n \tpp = pd-\u003epp;\n \n-\t/* Cannot handle fragmented embedded protocol */\n-\tif (ciph.fragoffs)\n+\t/* Is the embedded protocol header present? */\n+\tif (ciph.fragoffs \u0026\u0026 !pp-\u003edont_defrag)\n \t\treturn NF_ACCEPT;\n \n \tIP_VS_DBG_PKT(11, AF_INET6, pp, skb, offset,\n@@ -2057,23 +2052,22 @@ static int ip_vs_in_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,\n \t\tnew_cp = true;\n \t}\n \n-\t/* VS/TUN, VS/DR and LOCALNODE just let it go */\n-\tif ((hooknum == NF_INET_LOCAL_OUT) \u0026\u0026\n-\t (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)) {\n-\t\tverdict = NF_ACCEPT;\n+\tverdict = NF_DROP;\n+\n+\t/* Ensure the checksum is correct */\n+\tif (IP_VS_FWD_METHOD(cp) == IP_VS_CONN_F_MASQ \u0026\u0026\n+\t !ip_vs_checksum_common_check(skb, iph-\u003elen, IPPROTO_ICMPV6,\n+\t\t\t\t\t AF_INET6)) {\n+\t\t/* Failed checksum! */\n+\t\tIP_VS_DBG(1, \"Incoming ICMPv6: failed checksum from %pI6c!\\n\",\n+\t\t\t \u0026iph-\u003esaddr);\n \t\tgoto out;\n \t}\n \n \t/* do the statistics and put it back */\n \tip_vs_in_stats(cp, skb);\n \n-\t/* Need to mangle contained IPv6 header in ICMPv6 packet */\n-\toffset = ciph.len;\n-\tif (IPPROTO_TCP == ciph.protocol || IPPROTO_UDP == ciph.protocol ||\n-\t IPPROTO_SCTP == ciph.protocol)\n-\t\toffset += 2 * sizeof(__u16); /* Also mangle ports */\n-\n-\tverdict = ip_vs_icmp_xmit_v6(skb, cp, pp, offset, hooknum, \u0026ciph);\n+\tverdict = ip_vs_icmp_xmit_v6(skb, cp, pp, iph-\u003elen, hooknum, \u0026ciph);\n \n out:\n \tif (likely(!new_cp))\n@@ -2152,7 +2146,7 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *state\n \t\tif (unlikely(iph.protocol == IPPROTO_ICMP)) {\n \t\t\tint related;\n \t\t\tint verdict = ip_vs_in_icmp(ipvs, skb, \u0026related,\n-\t\t\t\t\t\t hooknum);\n+\t\t\t\t\t\t hooknum, \u0026iph);\n \n \t\t\tif (related)\n \t\t\t\treturn verdict;\n@@ -2200,8 +2194,11 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *state\n \t\t}\n \n \t\tif (resched) {\n-\t\t\tif (!old_ct)\n+\t\t\tif (!old_ct) {\n+\t\t\t\tspin_lock_bh(\u0026cp-\u003elock);\n \t\t\t\tcp-\u003eflags \u0026= ~IP_VS_CONN_F_NFCT;\n+\t\t\t\tspin_unlock_bh(\u0026cp-\u003elock);\n+\t\t\t}\n \t\t\tif (!atomic_read(\u0026cp-\u003en_control))\n \t\t\t\tip_vs_conn_expire_now(cp);\n \t\t\t__ip_vs_conn_put(cp);\n@@ -2217,8 +2214,11 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *state\n \t\tif (sysctl_expire_nodest_conn(ipvs)) {\n \t\t\tbool old_ct = ip_vs_conn_uses_old_conntrack(cp, skb);\n \n-\t\t\tif (!old_ct)\n+\t\t\tif (!old_ct) {\n+\t\t\t\tspin_lock_bh(\u0026cp-\u003elock);\n \t\t\t\tcp-\u003eflags \u0026= ~IP_VS_CONN_F_NFCT;\n+\t\t\t\tspin_unlock_bh(\u0026cp-\u003elock);\n+\t\t\t}\n \n \t\t\tip_vs_conn_expire_now(cp);\n \t\t\t__ip_vs_conn_put(cp);\n@@ -2288,6 +2288,7 @@ ip_vs_forward_icmp(void *priv, struct sk_buff *skb,\n \t\t const struct nf_hook_state *state)\n {\n \tstruct netns_ipvs *ipvs = net_ipvs(state-\u003enet);\n+\tstruct ip_vs_iphdr iphdr;\n \tint r;\n \n \t/* ipvs enabled in this netns ? */\n@@ -2297,10 +2298,9 @@ ip_vs_forward_icmp(void *priv, struct sk_buff *skb,\n \tif (state-\u003epf == NFPROTO_IPV4) {\n \t\tif (ip_hdr(skb)-\u003eprotocol != IPPROTO_ICMP)\n \t\t\treturn NF_ACCEPT;\n+\t\tip_vs_fill_iph_skb(AF_INET, skb, false, \u0026iphdr);\n #ifdef CONFIG_IP_VS_IPV6\n \t} else {\n-\t\tstruct ip_vs_iphdr iphdr;\n-\n \t\tip_vs_fill_iph_skb(AF_INET6, skb, false, \u0026iphdr);\n \n \t\tif (iphdr.protocol != IPPROTO_ICMPV6)\n@@ -2310,7 +2310,7 @@ ip_vs_forward_icmp(void *priv, struct sk_buff *skb,\n #endif\n \t}\n \n-\treturn ip_vs_in_icmp(ipvs, skb, \u0026r, state-\u003ehook);\n+\treturn ip_vs_in_icmp(ipvs, skb, \u0026r, state-\u003ehook, \u0026iphdr);\n }\n \n static const struct nf_hook_ops ip_vs_ops4[] = {\ndiff --git a/net/netfilter/ipvs/ip_vs_proto_sctp.c b/net/netfilter/ipvs/ip_vs_proto_sctp.c\nindex c67317be17dfaf..3dbd3096e1637b 100644\n--- a/net/netfilter/ipvs/ip_vs_proto_sctp.c\n+++ b/net/netfilter/ipvs/ip_vs_proto_sctp.c\n@@ -11,7 +11,7 @@\n \n static int\n sctp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,\n-\t\tunsigned int sctphoff);\n+\t\tstruct ip_vs_iphdr *iph);\n \n static int\n sctp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,\n@@ -109,7 +109,7 @@ sctp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\tint ret;\n \n \t\t/* Some checks before mangling */\n-\t\tif (!sctp_csum_check(cp-\u003eaf, skb, pp, sctphoff))\n+\t\tif (!sctp_csum_check(cp-\u003eaf, skb, pp, iph))\n \t\t\treturn 0;\n \n \t\t/* Call application helper if needed */\n@@ -121,7 +121,7 @@ sctp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\t\tpayload_csum = true;\n \t}\n \n-\tsctph = (void *) skb_network_header(skb) + sctphoff;\n+\tsctph = (void *)skb-\u003edata + sctphoff;\n \n \t/* Only update csum if we really have to */\n \tif (sctph-\u003esource != cp-\u003evport || payload_csum ||\n@@ -157,7 +157,7 @@ sctp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\tint ret;\n \n \t\t/* Some checks before mangling */\n-\t\tif (!sctp_csum_check(cp-\u003eaf, skb, pp, sctphoff))\n+\t\tif (!sctp_csum_check(cp-\u003eaf, skb, pp, iph))\n \t\t\treturn 0;\n \n \t\t/* Call application helper if needed */\n@@ -169,7 +169,7 @@ sctp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\t\tpayload_csum = true;\n \t}\n \n-\tsctph = (void *) skb_network_header(skb) + sctphoff;\n+\tsctph = (void *)skb-\u003edata + sctphoff;\n \n \t/* Only update csum if we really have to */\n \tif (sctph-\u003edest != cp-\u003edport || payload_csum ||\n@@ -187,19 +187,22 @@ sctp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \n static int\n sctp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,\n-\t\tunsigned int sctphoff)\n+\t\tstruct ip_vs_iphdr *iph)\n {\n+\tunsigned int sctphoff = iph-\u003elen;\n \tstruct sctphdr *sh;\n \t__le32 cmp, val;\n \n+\tif (!ip_vs_checksum_needed(skb, af))\n+\t\treturn 1;\n \tsh = (struct sctphdr *)(skb-\u003edata + sctphoff);\n \tcmp = sh-\u003echecksum;\n \tval = sctp_compute_cksum(skb, sctphoff);\n \n \tif (val != cmp) {\n \t\t/* CRC failure, dump it. */\n-\t\tIP_VS_DBG_RL_PKT(0, af, pp, skb, 0,\n-\t\t\t\t\"Failed checksum for\");\n+\t\tIP_VS_DBG_RL_PKT(0, af, pp, skb, iph-\u003eoff,\n+\t\t\t\t \"Failed checksum for\");\n \t\treturn 0;\n \t}\n \treturn 1;\ndiff --git a/net/netfilter/ipvs/ip_vs_proto_tcp.c b/net/netfilter/ipvs/ip_vs_proto_tcp.c\nindex f86b763efcc4dc..99a286fdc90c65 100644\n--- a/net/netfilter/ipvs/ip_vs_proto_tcp.c\n+++ b/net/netfilter/ipvs/ip_vs_proto_tcp.c\n@@ -29,7 +29,7 @@\n \n static int\n tcp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,\n-\t unsigned int tcphoff);\n+\t struct ip_vs_iphdr *iph);\n \n static int\n tcp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,\n@@ -166,7 +166,7 @@ tcp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\tint ret;\n \n \t\t/* Some checks before mangling */\n-\t\tif (!tcp_csum_check(cp-\u003eaf, skb, pp, tcphoff))\n+\t\tif (!tcp_csum_check(cp-\u003eaf, skb, pp, iph))\n \t\t\treturn 0;\n \n \t\t/* Call application helper if needed */\n@@ -179,7 +179,7 @@ tcp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\t\tpayload_csum = true;\n \t}\n \n-\ttcph = (void *)skb_network_header(skb) + tcphoff;\n+\ttcph = (void *)skb-\u003edata + tcphoff;\n \ttcph-\u003esource = cp-\u003evport;\n \n \t/* Adjust TCP checksums */\n@@ -244,7 +244,7 @@ tcp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\tint ret;\n \n \t\t/* Some checks before mangling */\n-\t\tif (!tcp_csum_check(cp-\u003eaf, skb, pp, tcphoff))\n+\t\tif (!tcp_csum_check(cp-\u003eaf, skb, pp, iph))\n \t\t\treturn 0;\n \n \t\t/*\n@@ -260,7 +260,7 @@ tcp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\t\tpayload_csum = true;\n \t}\n \n-\ttcph = (void *)skb_network_header(skb) + tcphoff;\n+\ttcph = (void *)skb-\u003edata + tcphoff;\n \ttcph-\u003edest = cp-\u003edport;\n \n \t/*\n@@ -302,41 +302,13 @@ tcp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \n static int\n tcp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,\n-\t unsigned int tcphoff)\n+\t struct ip_vs_iphdr *iph)\n {\n-\tswitch (skb-\u003eip_summed) {\n-\tcase CHECKSUM_NONE:\n-\t\tskb-\u003ecsum = skb_checksum(skb, tcphoff, skb-\u003elen - tcphoff, 0);\n-\t\tfallthrough;\n-\tcase CHECKSUM_COMPLETE:\n-#ifdef CONFIG_IP_VS_IPV6\n-\t\tif (af == AF_INET6) {\n-\t\t\tif (csum_ipv6_magic(\u0026ipv6_hdr(skb)-\u003esaddr,\n-\t\t\t\t\t \u0026ipv6_hdr(skb)-\u003edaddr,\n-\t\t\t\t\t skb-\u003elen - tcphoff,\n-\t\t\t\t\t IPPROTO_TCP,\n-\t\t\t\t\t skb-\u003ecsum)) {\n-\t\t\t\tIP_VS_DBG_RL_PKT(0, af, pp, skb, 0,\n-\t\t\t\t\t\t \"Failed checksum for\");\n-\t\t\t\treturn 0;\n-\t\t\t}\n-\t\t} else\n-#endif\n-\t\t\tif (csum_tcpudp_magic(ip_hdr(skb)-\u003esaddr,\n-\t\t\t\t\t ip_hdr(skb)-\u003edaddr,\n-\t\t\t\t\t skb-\u003elen - tcphoff,\n-\t\t\t\t\t ip_hdr(skb)-\u003eprotocol,\n-\t\t\t\t\t skb-\u003ecsum)) {\n-\t\t\t\tIP_VS_DBG_RL_PKT(0, af, pp, skb, 0,\n-\t\t\t\t\t\t \"Failed checksum for\");\n-\t\t\t\treturn 0;\n-\t\t\t}\n-\t\tbreak;\n-\tdefault:\n-\t\t/* No need to checksum. */\n-\t\tbreak;\n+\tif (!ip_vs_checksum_common_check(skb, iph-\u003elen, IPPROTO_TCP, af)) {\n+\t\tIP_VS_DBG_RL_PKT(0, af, pp, skb, iph-\u003eoff,\n+\t\t\t\t \"Failed checksum for\");\n+\t\treturn 0;\n \t}\n-\n \treturn 1;\n }\n \ndiff --git a/net/netfilter/ipvs/ip_vs_proto_udp.c b/net/netfilter/ipvs/ip_vs_proto_udp.c\nindex 58f9e255927e2e..f32785682402dd 100644\n--- a/net/netfilter/ipvs/ip_vs_proto_udp.c\n+++ b/net/netfilter/ipvs/ip_vs_proto_udp.c\n@@ -25,7 +25,7 @@\n \n static int\n udp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,\n-\t unsigned int udphoff);\n+\t struct ip_vs_iphdr *iph);\n \n static int\n udp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,\n@@ -155,7 +155,7 @@ udp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\tint ret;\n \n \t\t/* Some checks before mangling */\n-\t\tif (!udp_csum_check(cp-\u003eaf, skb, pp, udphoff))\n+\t\tif (!udp_csum_check(cp-\u003eaf, skb, pp, iph))\n \t\t\treturn 0;\n \n \t\t/*\n@@ -170,7 +170,7 @@ udp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\t\tpayload_csum = true;\n \t}\n \n-\tudph = (void *)skb_network_header(skb) + udphoff;\n+\tudph = (void *)skb-\u003edata + udphoff;\n \tudph-\u003esource = cp-\u003evport;\n \n \t/*\n@@ -238,7 +238,7 @@ udp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\tint ret;\n \n \t\t/* Some checks before mangling */\n-\t\tif (!udp_csum_check(cp-\u003eaf, skb, pp, udphoff))\n+\t\tif (!udp_csum_check(cp-\u003eaf, skb, pp, iph))\n \t\t\treturn 0;\n \n \t\t/*\n@@ -254,7 +254,7 @@ udp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \t\t\tpayload_csum = true;\n \t}\n \n-\tudph = (void *)skb_network_header(skb) + udphoff;\n+\tudph = (void *)skb-\u003edata + udphoff;\n \tudph-\u003edest = cp-\u003edport;\n \n \t/*\n@@ -298,48 +298,20 @@ udp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,\n \n static int\n udp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,\n-\t unsigned int udphoff)\n+\t struct ip_vs_iphdr *iph)\n {\n \tstruct udphdr _udph, *uh;\n \n-\tuh = skb_header_pointer(skb, udphoff, sizeof(_udph), \u0026_udph);\n+\tuh = skb_header_pointer(skb, iph-\u003elen, sizeof(_udph), \u0026_udph);\n \tif (uh == NULL)\n \t\treturn 0;\n \n-\tif (uh-\u003echeck != 0) {\n-\t\tswitch (skb-\u003eip_summed) {\n-\t\tcase CHECKSUM_NONE:\n-\t\t\tskb-\u003ecsum = skb_checksum(skb, udphoff,\n-\t\t\t\t\t\t skb-\u003elen - udphoff, 0);\n-\t\t\tfallthrough;\n-\t\tcase CHECKSUM_COMPLETE:\n-#ifdef CONFIG_IP_VS_IPV6\n-\t\t\tif (af == AF_INET6) {\n-\t\t\t\tif (csum_ipv6_magic(\u0026ipv6_hdr(skb)-\u003esaddr,\n-\t\t\t\t\t\t \u0026ipv6_hdr(skb)-\u003edaddr,\n-\t\t\t\t\t\t skb-\u003elen - udphoff,\n-\t\t\t\t\t\t IPPROTO_UDP,\n-\t\t\t\t\t\t skb-\u003ecsum)) {\n-\t\t\t\t\tIP_VS_DBG_RL_PKT(0, af, pp, skb, 0,\n-\t\t\t\t\t\t\t \"Failed checksum for\");\n-\t\t\t\t\treturn 0;\n-\t\t\t\t}\n-\t\t\t} else\n-#endif\n-\t\t\t\tif (csum_tcpudp_magic(ip_hdr(skb)-\u003esaddr,\n-\t\t\t\t\t\t ip_hdr(skb)-\u003edaddr,\n-\t\t\t\t\t\t skb-\u003elen - udphoff,\n-\t\t\t\t\t\t ip_hdr(skb)-\u003eprotocol,\n-\t\t\t\t\t\t skb-\u003ecsum)) {\n-\t\t\t\t\tIP_VS_DBG_RL_PKT(0, af, pp, skb, 0,\n-\t\t\t\t\t\t\t \"Failed checksum for\");\n-\t\t\t\t\treturn 0;\n-\t\t\t\t}\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\t/* No need to checksum. */\n-\t\t\tbreak;\n-\t\t}\n+\tif (!uh-\u003echeck)\n+\t\treturn 1;\n+\tif (!ip_vs_checksum_common_check(skb, iph-\u003elen, IPPROTO_UDP, af)) {\n+\t\tIP_VS_DBG_RL_PKT(0, af, pp, skb, iph-\u003eoff,\n+\t\t\t\t \"Failed checksum for\");\n+\t\treturn 0;\n \t}\n \treturn 1;\n }\ndiff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c\nindex 9fef4335da13fd..0b0c5304993a91 100644\n--- a/net/netfilter/ipvs/ip_vs_xmit.c\n+++ b/net/netfilter/ipvs/ip_vs_xmit.c\n@@ -1502,20 +1502,22 @@ ip_vs_dr_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,\n */\n int\n ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,\n-\t\tstruct ip_vs_protocol *pp, int offset, unsigned int hooknum,\n-\t\tstruct ip_vs_iphdr *iph)\n+\t\tstruct ip_vs_protocol *pp, unsigned int toff,\n+\t\tunsigned int hooknum, struct ip_vs_iphdr *ciph)\n {\n \tstruct rtable\t*rt;\t/* Route to the other host */\n \tint rc;\n \tint local;\n \tint rt_mode, was_input;\n+\tbool has_ports = false;\n+\tunsigned int wlen;\n \n \t/* The ICMP packet for VS/TUN, VS/DR and LOCALNODE will be\n \t forwarded directly here, because there is no need to\n \t translate address/port back */\n \tif (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ) {\n \t\tif (cp-\u003epacket_xmit)\n-\t\t\trc = cp-\u003epacket_xmit(skb, cp, pp, iph);\n+\t\t\trc = cp-\u003epacket_xmit(skb, cp, pp, ciph);\n \t\telse\n \t\t\trc = NF_ACCEPT;\n \t\t/* do not touch skb anymore */\n@@ -1533,7 +1535,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,\n \t\t IP_VS_RT_MODE_LOCAL | IP_VS_RT_MODE_NON_LOCAL |\n \t\t IP_VS_RT_MODE_RDR : IP_VS_RT_MODE_NON_LOCAL;\n \tlocal = __ip_vs_get_out_rt(cp-\u003eipvs, cp-\u003eaf, skb, cp-\u003edest, cp-\u003edaddr.ip, rt_mode,\n-\t\t\t\t NULL, iph);\n+\t\t\t\t NULL, ciph);\n \tif (local \u003c 0)\n \t\tgoto tx_error;\n \trt = skb_rtable(skb);\n@@ -1564,14 +1566,21 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,\n \t\tgoto tx_error;\n \t}\n \n+\twlen = ciph-\u003elen;\n+\tif (ciph-\u003eprotocol == IPPROTO_TCP || ciph-\u003eprotocol == IPPROTO_UDP ||\n+\t ciph-\u003eprotocol == IPPROTO_SCTP) {\n+\t\twlen += 2 * sizeof(__u16); /* Also mangle ports */\n+\t\thas_ports = true;\n+\t}\n+\n \t/* copy-on-write the packet before mangling it */\n-\tif (skb_ensure_writable(skb, offset))\n+\tif (skb_ensure_writable(skb, wlen))\n \t\tgoto tx_error;\n \n \tif (skb_cow(skb, rt-\u003edst.dev-\u003ehard_header_len))\n \t\tgoto tx_error;\n \n-\tip_vs_nat_icmp(skb, pp, cp, 0);\n+\tip_vs_nat_icmp(skb, pp, cp, 0, toff, has_ports);\n \n \t/* Another hack: avoid icmp_send in ip_fragment */\n \tskb-\u003eignore_df = 1;\n@@ -1587,10 +1596,12 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,\n #ifdef CONFIG_IP_VS_IPV6\n int\n ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,\n-\t\tstruct ip_vs_protocol *pp, int offset, unsigned int hooknum,\n-\t\tstruct ip_vs_iphdr *ipvsh)\n+\t\tstruct ip_vs_protocol *pp, unsigned int toff,\n+\t\tunsigned int hooknum, struct ip_vs_iphdr *ciph)\n {\n+\tbool has_ports = false;\n \tstruct rt6_info\t*rt;\t/* Route to the other host */\n+\tunsigned int wlen;\n \tint rc;\n \tint local;\n \tint rt_mode;\n@@ -1600,7 +1611,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,\n \t translate address/port back */\n \tif (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ) {\n \t\tif (cp-\u003epacket_xmit)\n-\t\t\trc = cp-\u003epacket_xmit(skb, cp, pp, ipvsh);\n+\t\t\trc = cp-\u003epacket_xmit(skb, cp, pp, ciph);\n \t\telse\n \t\t\trc = NF_ACCEPT;\n \t\t/* do not touch skb anymore */\n@@ -1617,7 +1628,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,\n \t\t IP_VS_RT_MODE_LOCAL | IP_VS_RT_MODE_NON_LOCAL |\n \t\t IP_VS_RT_MODE_RDR : IP_VS_RT_MODE_NON_LOCAL;\n \tlocal = __ip_vs_get_out_rt_v6(cp-\u003eipvs, cp-\u003eaf, skb, cp-\u003edest,\n-\t\t\t\t \u0026cp-\u003edaddr.in6, NULL, ipvsh, 0, rt_mode);\n+\t\t\t\t \u0026cp-\u003edaddr.in6, NULL, ciph, 0, rt_mode);\n \tif (local \u003c 0)\n \t\tgoto tx_error;\n \trt = dst_rt6_info(skb_dst(skb));\n@@ -1648,14 +1659,21 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,\n \t\tgoto tx_error;\n \t}\n \n+\twlen = ciph-\u003elen;\n+\tif (ciph-\u003eprotocol == IPPROTO_TCP || ciph-\u003eprotocol == IPPROTO_UDP ||\n+\t ciph-\u003eprotocol == IPPROTO_SCTP) {\n+\t\twlen += 2 * sizeof(__u16); /* Also mangle ports */\n+\t\thas_ports = true;\n+\t}\n+\n \t/* copy-on-write the packet before mangling it */\n-\tif (skb_ensure_writable(skb, offset))\n+\tif (skb_ensure_writable(skb, wlen))\n \t\tgoto tx_error;\n \n \tif (skb_cow(skb, rt-\u003edst.dev-\u003ehard_header_len))\n \t\tgoto tx_error;\n \n-\tip_vs_nat_icmp_v6(skb, pp, cp, 0);\n+\tip_vs_nat_icmp_v6(skb, pp, cp, 0, toff, has_ports, ciph);\n \n \t/* Another hack: avoid icmp_send in ip_fragment */\n \tskb-\u003eignore_df = 1;\ndiff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c\nindex 7ae68d60586a23..8a3b9e33e94f77 100644\n--- a/net/netfilter/nf_conntrack_expect.c\n+++ b/net/netfilter/nf_conntrack_expect.c\n@@ -427,7 +427,6 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp,\n \t\texp-\u003etimeout += helper-\u003eexpect_policy[exp-\u003eclass].timeout * HZ;\n \n \thlist_add_head_rcu(\u0026exp-\u003elnode, \u0026master_help-\u003eexpectations);\n-\tmaster_help-\u003eexpecting[exp-\u003eclass]++;\n \n \thlist_add_head_rcu(\u0026exp-\u003ehnode, \u0026nf_ct_expect_hash[h]);\n \tcnet = nf_ct_pernet(net);\n@@ -534,6 +533,7 @@ int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,\n \tif (ret \u003c 0)\n \t\tgoto out;\n \n+\tmaster_help-\u003eexpecting[expect-\u003eclass]++;\n \tnf_ct_expect_insert(expect, master_help);\n \n \tnf_ct_expect_event_report(IPEXP_NEW, expect, portid, report);\n@@ -546,6 +546,39 @@ int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,\n }\n EXPORT_SYMBOL_GPL(nf_ct_expect_related_report);\n \n+int nf_ct_expect_related_pair(struct nf_conntrack_expect *expect[],\n+\t\t\t unsigned int flags)\n+{\n+\tstruct nf_conn_help *master_help;\n+\tint i, ret;\n+\n+\tspin_lock_bh(\u0026nf_conntrack_expect_lock);\n+\tmaster_help = nfct_help(expect[0]-\u003emaster);\n+\tif (!master_help || master_help != nfct_help(expect[1]-\u003emaster)) {\n+\t\tret = -EINVAL;\n+\t\tgoto out;\n+\t}\n+\n+\tfor (i = 0; i \u003c 2; i++) {\n+\t\tret = __nf_ct_expect_check(expect[i], master_help, flags);\n+\t\tif (ret \u003c 0) {\n+\t\t\tif (i == 1)\n+\t\t\t\tmaster_help-\u003eexpecting[expect[0]-\u003eclass]--;\n+\t\t\tgoto out;\n+\t\t}\n+\t\tmaster_help-\u003eexpecting[expect[i]-\u003eclass]++;\n+\t}\n+\n+\tfor (i = 0; i \u003c 2; i++) {\n+\t\tnf_ct_expect_insert(expect[i], master_help);\n+\t\tnf_ct_expect_event_report(IPEXP_NEW, expect[i], 0, 0);\n+\t}\n+out:\n+\tspin_unlock_bh(\u0026nf_conntrack_expect_lock);\n+\treturn ret;\n+}\n+EXPORT_SYMBOL_GPL(nf_ct_expect_related_pair);\n+\n void nf_ct_expect_iterate_destroy(bool (*iter)(struct nf_conntrack_expect *e, void *data),\n \t\t\t\t void *data)\n {\ndiff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c\nindex f3f90a86633894..e4a70d1d77b0b9 100644\n--- a/net/netfilter/nf_conntrack_sip.c\n+++ b/net/netfilter/nf_conntrack_sip.c\n@@ -1663,7 +1663,7 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff,\n \tunsigned int matchoff, matchlen;\n \tunsigned int msglen, origlen;\n \tconst char *dptr, *end;\n-\ts16 diff, tdiff = 0;\n+\ts32 diff, tdiff = 0;\n \tint ret = NF_ACCEPT;\n \tunsigned long clen;\n \tbool term;\ndiff --git a/net/netfilter/nf_nat_sip.c b/net/netfilter/nf_nat_sip.c\nindex aea02f6aff092a..133bd713fe0c29 100644\n--- a/net/netfilter/nf_nat_sip.c\n+++ b/net/netfilter/nf_nat_sip.c\n@@ -321,7 +321,7 @@ static unsigned int nf_nat_sip(struct sk_buff *skb, unsigned int protoff,\n }\n \n static void nf_nat_sip_seq_adjust(struct sk_buff *skb, unsigned int protoff,\n-\t\t\t\t s16 off)\n+\t\t\t\t s32 off)\n {\n \tenum ip_conntrack_info ctinfo;\n \tstruct nf_conn *ct = nf_ct_get(skb, \u0026ctinfo);\n@@ -592,6 +592,7 @@ static unsigned int nf_nat_sdp_media(struct sk_buff *skb, unsigned int protoff,\n \t\t\t\t unsigned int medialen,\n \t\t\t\t union nf_inet_addr *rtp_addr)\n {\n+\tstruct nf_conntrack_expect *rtp_pair[2] = { rtp_exp, rtcp_exp };\n \tenum ip_conntrack_info ctinfo;\n \tstruct nf_conn *ct = nf_ct_get(skb, \u0026ctinfo);\n \tenum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);\n@@ -622,24 +623,15 @@ static unsigned int nf_nat_sdp_media(struct sk_buff *skb, unsigned int protoff,\n \t\tint ret;\n \n \t\trtp_exp-\u003etuple.dst.u.udp.port = htons(port);\n-\t\tret = nf_ct_expect_related(rtp_exp,\n-\t\t\t\t\t NF_CT_EXP_F_SKIP_MASTER);\n-\t\tif (ret == -EBUSY)\n-\t\t\tcontinue;\n-\t\telse if (ret \u003c 0) {\n-\t\t\tport = 0;\n-\t\t\tbreak;\n-\t\t}\n \t\trtcp_exp-\u003etuple.dst.u.udp.port = htons(port + 1);\n-\t\tret = nf_ct_expect_related(rtcp_exp,\n-\t\t\t\t\t NF_CT_EXP_F_SKIP_MASTER);\n+\n+\t\tret = nf_ct_expect_related_pair(rtp_pair,\n+\t\t\t\t\t\tNF_CT_EXP_F_SKIP_MASTER);\n \t\tif (ret == 0)\n \t\t\tbreak;\n-\t\telse if (ret == -EBUSY) {\n-\t\t\tnf_ct_unexpect_related(rtp_exp);\n+\t\telse if (ret == -EBUSY)\n \t\t\tcontinue;\n-\t\t} else if (ret \u003c 0) {\n-\t\t\tnf_ct_unexpect_related(rtp_exp);\n+\t\telse if (ret \u003c 0) {\n \t\t\tport = 0;\n \t\t\tbreak;\n \t\t}\ndiff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c\nindex a9eaf9455c7783..af357f6c5070b1 100644\n--- a/net/netfilter/nf_tables_api.c\n+++ b/net/netfilter/nf_tables_api.c\n@@ -45,8 +45,6 @@ enum {\n \tNFT_VALIDATE_DO,\n };\n \n-static struct rhltable nft_objname_ht;\n-\n static u32 nft_chain_hash(const void *data, u32 len, u32 seed);\n static u32 nft_chain_hash_obj(const void *data, u32 len, u32 seed);\n static int nft_chain_hash_cmp(struct rhashtable_compare_arg *, const void *);\n@@ -1635,6 +1633,10 @@ static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,\n \tif (err)\n \t\tgoto err_chain_ht;\n \n+\terr = rhltable_init(\u0026table-\u003eobjname_ht, \u0026nft_objname_ht_params);\n+\tif (err \u003c 0)\n+\t\tgoto err_obj_ht;\n+\n \tINIT_LIST_HEAD(\u0026table-\u003echains);\n \tINIT_LIST_HEAD(\u0026table-\u003esets);\n \tINIT_LIST_HEAD(\u0026table-\u003eobjects);\n@@ -1653,6 +1655,8 @@ static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,\n \tlist_add_tail_rcu(\u0026table-\u003elist, \u0026nft_net-\u003etables);\n \treturn 0;\n err_trans:\n+\trhltable_destroy(\u0026table-\u003eobjname_ht);\n+err_obj_ht:\n \trhltable_destroy(\u0026table-\u003echains_ht);\n err_chain_ht:\n \tkfree(table-\u003eudata);\n@@ -1819,6 +1823,7 @@ static void nf_tables_table_destroy(struct nft_table *table)\n \t\treturn;\n \n \trhltable_destroy(\u0026table-\u003echains_ht);\n+\trhltable_destroy(\u0026table-\u003eobjname_ht);\n \tkfree(table-\u003ename);\n \tkfree(table-\u003eudata);\n \tkfree(table);\n@@ -8086,7 +8091,7 @@ void nft_unregister_obj(struct nft_object_type *obj_type)\n EXPORT_SYMBOL_GPL(nft_unregister_obj);\n \n struct nft_object *nft_obj_lookup(const struct net *net,\n-\t\t\t\t const struct nft_table *table,\n+\t\t\t\t struct nft_table *table,\n \t\t\t\t const struct nlattr *nla, u32 objtype,\n \t\t\t\t u8 genmask)\n {\n@@ -8102,7 +8107,7 @@ struct nft_object *nft_obj_lookup(const struct net *net,\n \t\t !lockdep_commit_lock_is_held(net));\n \n \trcu_read_lock();\n-\tlist = rhltable_lookup(\u0026nft_objname_ht, \u0026k, nft_objname_ht_params);\n+\tlist = rhltable_lookup(\u0026table-\u003eobjname_ht, \u0026k, nft_objname_ht_params);\n \tif (!list)\n \t\tgoto out;\n \n@@ -8382,7 +8387,7 @@ static int nf_tables_newobj(struct sk_buff *skb, const struct nfnl_info *info,\n \tif (err \u003c 0)\n \t\tgoto err_trans;\n \n-\terr = rhltable_insert(\u0026nft_objname_ht, \u0026obj-\u003erhlhead,\n+\terr = rhltable_insert(\u0026table-\u003eobjname_ht, \u0026obj-\u003erhlhead,\n \t\t\t nft_objname_ht_params);\n \tif (err \u003c 0)\n \t\tgoto err_obj_ht;\n@@ -8567,8 +8572,8 @@ nf_tables_getobj_single(u32 portid, const struct nfnl_info *info,\n \tstruct netlink_ext_ack *extack = info-\u003eextack;\n \tu8 genmask = nft_genmask_cur(info-\u003enet);\n \tu8 family = info-\u003enfmsg-\u003enfgen_family;\n-\tconst struct nft_table *table;\n \tstruct net *net = info-\u003enet;\n+\tstruct nft_table *table;\n \tstruct nft_object *obj;\n \tstruct sk_buff *skb2;\n \tu32 objtype;\n@@ -10437,9 +10442,9 @@ static void nf_tables_commit_chain(struct net *net, struct nft_chain *chain)\n \t\tnf_tables_commit_chain_free_rules_old(g0);\n }\n \n-static void nft_obj_del(struct nft_object *obj)\n+static void nft_obj_del(struct nft_table *table, struct nft_object *obj)\n {\n-\trhltable_remove(\u0026nft_objname_ht, \u0026obj-\u003erhlhead, nft_objname_ht_params);\n+\trhltable_remove(\u0026table-\u003eobjname_ht, \u0026obj-\u003erhlhead, nft_objname_ht_params);\n \tlist_del_rcu(\u0026obj-\u003elist);\n }\n \n@@ -11124,7 +11129,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)\n \t\t\tbreak;\n \t\tcase NFT_MSG_DELOBJ:\n \t\tcase NFT_MSG_DESTROYOBJ:\n-\t\t\tnft_obj_del(nft_trans_obj(trans));\n+\t\t\tnft_obj_del(table, nft_trans_obj(trans));\n \t\t\tnf_tables_obj_notify(\u0026ctx, nft_trans_obj(trans),\n \t\t\t\t\t trans-\u003emsg_type);\n \t\t\tbreak;\n@@ -11416,7 +11421,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)\n \t\t\t\tnft_trans_destroy(trans);\n \t\t\t} else {\n \t\t\t\tnft_use_dec_restore(\u0026table-\u003euse);\n-\t\t\t\tnft_obj_del(nft_trans_obj(trans));\n+\t\t\t\tnft_obj_del(table, nft_trans_obj(trans));\n \t\t\t}\n \t\t\tbreak;\n \t\tcase NFT_MSG_DELOBJ:\n@@ -12043,7 +12048,7 @@ static void __nft_release_table(struct net *net, struct nft_table *table)\n \t\tnft_set_destroy(\u0026ctx, set);\n \t}\n \tlist_for_each_entry_safe(obj, ne, \u0026table-\u003eobjects, list) {\n-\t\tnft_obj_del(obj);\n+\t\tnft_obj_del(table, obj);\n \t\tnft_use_dec(\u0026table-\u003euse);\n \t\tnft_obj_destroy(\u0026ctx, obj);\n \t}\n@@ -12225,10 +12230,6 @@ static int __init nf_tables_module_init(void)\n \tif (err \u003c 0)\n \t\tgoto err_netdev_notifier;\n \n-\terr = rhltable_init(\u0026nft_objname_ht, \u0026nft_objname_ht_params);\n-\tif (err \u003c 0)\n-\t\tgoto err_rht_objname;\n-\n \terr = nft_offload_init();\n \tif (err \u003c 0)\n \t\tgoto err_offload;\n@@ -12251,8 +12252,6 @@ static int __init nf_tables_module_init(void)\n err_netlink_notifier:\n \tnft_offload_exit();\n err_offload:\n-\trhltable_destroy(\u0026nft_objname_ht);\n-err_rht_objname:\n \tunregister_netdevice_notifier(\u0026nf_tables_flowtable_notifier);\n err_netdev_notifier:\n \tnf_tables_core_module_exit();\n@@ -12274,7 +12273,6 @@ static void __exit nf_tables_module_exit(void)\n \tunregister_pernet_subsys(\u0026nf_tables_net_ops);\n \tcancel_work_sync(\u0026trans_gc_work);\n \trcu_barrier();\n-\trhltable_destroy(\u0026nft_objname_ht);\n \tnf_tables_core_module_exit();\n }\n \ndiff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c\nindex 391539a1ceaa77..8a4472fd77d9f2 100644\n--- a/net/netfilter/nft_payload.c\n+++ b/net/netfilter/nft_payload.c\n@@ -259,9 +259,7 @@ static int nft_payload_dump(struct sk_buff *skb,\n static bool nft_payload_offload_mask(struct nft_offload_reg *reg,\n \t\t\t\t u32 priv_len, u32 field_len)\n {\n-\tunsigned int remainder, delta, k;\n \tstruct nft_data mask = {};\n-\t__be32 remainder_mask;\n \n \tif (priv_len == field_len) {\n \t\tmemset(\u0026reg-\u003emask, 0xff, priv_len);\n@@ -270,15 +268,7 @@ static bool nft_payload_offload_mask(struct nft_offload_reg *reg,\n \t\treturn false;\n \t}\n \n-\tmemset(\u0026mask, 0xff, field_len);\n-\tremainder = priv_len % sizeof(u32);\n-\tif (remainder) {\n-\t\tk = priv_len / sizeof(u32);\n-\t\tdelta = field_len - priv_len;\n-\t\tremainder_mask = htonl(~((1 \u003c\u003c (delta * BITS_PER_BYTE)) - 1));\n-\t\tmask.data[k] = (__force u32)remainder_mask;\n-\t}\n-\n+\tmemset(\u0026mask, 0xff, priv_len);\n \tmemcpy(\u0026reg-\u003emask, \u0026mask, field_len);\n \n \treturn true;\ndiff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c\nindex 2704b4b60d1e04..9af0fa895f7302 100644\n--- a/net/netfilter/xt_hashlimit.c\n+++ b/net/netfilter/xt_hashlimit.c\n@@ -117,6 +117,7 @@ struct xt_hashlimit_htable {\n \trefcount_t use;\n \tu_int8_t family;\n \tbool rnd_initialized;\n+\tbool ratematch;\n \n \tstruct hashlimit_cfg3 cfg;\t/* config */\n \n@@ -323,6 +324,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,\n \t\tkvfree(hinfo);\n \t\treturn -ENOMEM;\n \t}\n+\thinfo-\u003eratematch = !!(cfg-\u003emode \u0026 XT_HASHLIMIT_RATE_MATCH);\n \tspin_lock_init(\u0026hinfo-\u003elock);\n \n \tswitch (revision) {\n@@ -872,7 +874,10 @@ static int hashlimit_mt_check_common(const struct xt_mtchk_param *par,\n \t}\n \n \t/* Check for overflow. */\n-\tif (revision \u003e= 3 \u0026\u0026 cfg-\u003emode \u0026 XT_HASHLIMIT_RATE_MATCH) {\n+\tif (cfg-\u003emode \u0026 XT_HASHLIMIT_RATE_MATCH) {\n+\t\tif (revision \u003c 3)\n+\t\t\treturn -EINVAL;\n+\n \t\tif (cfg-\u003eavg == 0 || cfg-\u003eavg \u003e U32_MAX) {\n \t\t\tpr_info_ratelimited(\"invalid rate\\n\");\n \t\t\treturn -ERANGE;\n@@ -905,6 +910,15 @@ static int hashlimit_mt_check_common(const struct xt_mtchk_param *par,\n \t\t\tmutex_unlock(\u0026hashlimit_mutex);\n \t\t\treturn ret;\n \t\t}\n+\t} else {\n+\t\tif ((cfg-\u003emode \u0026 XT_HASHLIMIT_RATE_MATCH \u0026\u0026\n+\t\t !(*hinfo)-\u003eratematch) ||\n+\t\t (!(cfg-\u003emode \u0026 XT_HASHLIMIT_RATE_MATCH) \u0026\u0026\n+\t\t (*hinfo)-\u003eratematch)) {\n+\t\t\tmutex_unlock(\u0026hashlimit_mutex);\n+\t\t\thtable_put(*hinfo);\n+\t\t\treturn -EINVAL;\n+\t\t}\n \t}\n \tmutex_unlock(\u0026hashlimit_mutex);\n \ndiff --git a/tools/testing/selftests/net/netfilter/nft_flowtable.sh b/tools/testing/selftests/net/netfilter/nft_flowtable.sh\nindex fb1c59d45567af..449c518bd947dc 100755\n--- a/tools/testing/selftests/net/netfilter/nft_flowtable.sh\n+++ b/tools/testing/selftests/net/netfilter/nft_flowtable.sh\n@@ -617,7 +617,11 @@ ip -6 -net \"$nsr2\" route add default via fee1:3::1\n ip -net \"$ns2\" route add default via 10.0.2.1\n ip -6 -net \"$ns2\" route add default via dead:2::1\n \n+ip netns exec \"$nsr1\" nft -a insert rule inet filter forward \\\n+\t'meta oif tun0 tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept'\n ip netns exec \"$nsr1\" nft -a insert rule inet filter forward 'meta oif tun0 accept'\n+ip netns exec \"$nsr1\" nft -a insert rule inet filter forward \\\n+\t'meta oif tun6 tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept'\n ip netns exec \"$nsr1\" nft -a insert rule inet filter forward 'meta oif tun6 accept'\n ip netns exec \"$nsr1\" nft -a insert rule inet filter forward \\\n \t'meta oif \"veth0\" tcp sport 12345 ct mark set 1 flow add @f1 counter name routed_repl accept'\n@@ -629,7 +633,7 @@ if ! test_tcp_forwarding_nat \"$ns1\" \"$ns2\" 1 \"IPIP tunnel\"; then\n fi\n \n if test_tcp_forwarding \"$ns1\" \"$ns2\" 1 6 \"[dead:2::99]\" 12345; then\n-\techo \"PASS: flow offload for ns1/ns2 IP6IP6 tunnel\"\n+\tcheck_counters \"flow offload for ns1/ns2 IP6IP6 tunnel\"\n else\n \techo \"FAIL: flow offload for ns1/ns2 with IP6IP6 tunnel\" 1\u003e\u00262\n \tip netns exec \"$nsr1\" nft list ruleset\n@@ -642,6 +646,8 @@ ip -net \"$nsr1\" link set veth1.10 up\n ip -net \"$nsr1\" addr add 192.168.20.1/24 dev veth1.10\n ip -net \"$nsr1\" addr add fee1:4::1/64 dev veth1.10 nodad\n ip netns exec \"$nsr1\" sysctl net.ipv4.conf.veth1/10.forwarding=1 \u003e /dev/null\n+ip netns exec \"$nsr1\" nft -a insert rule inet filter forward \\\n+\t'meta oif veth1.10 tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept'\n ip netns exec \"$nsr1\" nft -a insert rule inet filter forward 'meta oif veth1.10 accept'\n \n ip -net \"$nsr1\" link add name tun0.10 type ipip local 192.168.20.1 remote 192.168.20.2\n@@ -649,6 +655,8 @@ ip -net \"$nsr1\" link set tun0.10 up\n ip -net \"$nsr1\" addr add 192.168.200.1/24 dev tun0.10\n ip -net \"$nsr1\" route change default via 192.168.200.2\n ip netns exec \"$nsr1\" sysctl net.ipv4.conf.tun0/10.forwarding=1 \u003e /dev/null\n+ip netns exec \"$nsr1\" nft -a insert rule inet filter forward \\\n+\t'meta oif tun0.10 tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept'\n ip netns exec \"$nsr1\" nft -a insert rule inet filter forward 'meta oif tun0.10 accept'\n \n ip -net \"$nsr1\" link add name tun6.10 type ip6tnl local fee1:4::1 remote fee1:4::2 encaplimit none\n@@ -656,6 +664,8 @@ ip -net \"$nsr1\" link set tun6.10 up\n ip -net \"$nsr1\" addr add fee1:5::1/64 dev tun6.10 nodad\n ip -6 -net \"$nsr1\" route delete default\n ip -6 -net \"$nsr1\" route add default via fee1:5::2\n+ip netns exec \"$nsr1\" nft -a insert rule inet filter forward \\\n+\t'meta oif tun6.10 tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept'\n ip netns exec \"$nsr1\" nft -a insert rule inet filter forward 'meta oif tun6.10 accept'\n \n ip -net \"$nsr2\" link add link veth0 name veth0.10 type vlan id 10\n@@ -683,7 +693,7 @@ if ! test_tcp_forwarding_nat \"$ns1\" \"$ns2\" 1 \"IPIP tunnel over vlan\"; then\n fi\n \n if test_tcp_forwarding \"$ns1\" \"$ns2\" 1 6 \"[dead:2::99]\" 12345; then\n-\techo \"PASS: flow offload for ns1/ns2 IP6IP6 tunnel over vlan\"\n+\tcheck_counters \"flow offload for ns1/ns2 IP6IP6 tunnel over vlan\"\n else\n \techo \"FAIL: flow offload for ns1/ns2 with IP6IP6 tunnel over vlan\" 1\u003e\u00262\n \tip netns exec \"$nsr1\" nft list ruleset\n"
} |
| 2/1 | 2026/07/23 23:37 | agent | patch-evaluator |
1mModel:best-expensive Args: null Results: {
"EnableConfigs": [
"IP_VS",
"IP_VS_IPV6",
"IP_VS_PROTO_TCP",
"IP_VS_PROTO_UDP",
"IP_VS_PROTO_SCTP",
"NF_CONNTRACK_SIP",
"NF_NAT_SIP",
"NF_CONNTRACK_H323",
"NF_NAT_H323",
"NF_TABLES",
"NETFILTER_XT_MATCH_HASHLIMIT"
],
"FocusSymbols": [
"ip_vs_conn_fill_cport",
"ip_vs_conn_change_fwd_mask",
"ip_vs_nat_icmp",
"ip_vs_nat_icmp_v6",
"ip_vs_out_icmp",
"ip_vs_in_icmp",
"ip_vs_icmp_xmit",
"ip_vs_icmp_xmit_v6",
"tcp_csum_check",
"udp_csum_check",
"sctp_csum_check",
"nf_ct_expect_related_pair",
"nat_rtp_rtcp",
"nf_nat_sdp_media",
"nft_obj_lookup",
"nf_tables_newtable",
"nf_tables_newobj",
"nft_obj_del",
"hashlimit_mt_check_common"
],
"Reasoning": "The patch series makes functional changes to multiple core networking and netfilter subsystems, including IPVS connection handling and ICMP/checksum processing, conntrack expectation handling for SIP and H.323, nf_tables object lookup mechanisms, and xt_hashlimit matching. These changes modify reachable kernel logic and should be fuzzed.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Do not list too generic configs (we already have them enabled). Only list those that specifically cover the modified code. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit 71d4942b84b5b2bf1ac7280cf9e102e20da445f2
Author: syz-cluster <triage@syzkaller.com>
Date: Thu Jul 23 23:37:52 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/linux/netfilter/nf_conntrack_sip.h b/include/linux/netfilter/nf_conntrack_sip.h
index dbc614dfe0d565..aafa0c04f917eb 100644
--- a/include/linux/netfilter/nf_conntrack_sip.h
+++ b/include/linux/netfilter/nf_conntrack_sip.h
@@ -115,7 +115,7 @@ struct nf_nat_sip_hooks {
unsigned int *datalen);
void (*seq_adjust)(struct sk_buff *skb,
- unsigned int protoff, s16 off);
+ unsigned int protoff, s32 off);
unsigned int (*expect)(struct sk_buff *skb,
unsigned int protoff,
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 417ff51f62fc8e..9ae9aad65541d3 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -25,7 +25,9 @@
#include <linux/netfilter.h> /* for union nf_inet_addr */
#include <linux/ip.h>
#include <linux/ipv6.h> /* for struct ipv6hdr */
+#include <net/route.h>
#include <net/ipv6.h>
+#include <net/ip6_fib.h>
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
#include <net/netfilter/nf_conntrack.h>
#endif
@@ -1972,8 +1974,8 @@ int ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
int ip_vs_dr_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
struct ip_vs_protocol *pp, struct ip_vs_iphdr *iph);
int ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
- struct ip_vs_protocol *pp, int offset,
- unsigned int hooknum, struct ip_vs_iphdr *iph);
+ struct ip_vs_protocol *pp, unsigned int toff,
+ unsigned int hooknum, struct ip_vs_iphdr *ciph);
void ip_vs_dest_dst_rcu_free(struct rcu_head *head);
#ifdef CONFIG_IP_VS_IPV6
@@ -1986,8 +1988,8 @@ int ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
int ip_vs_dr_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
struct ip_vs_protocol *pp, struct ip_vs_iphdr *iph);
int ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
- struct ip_vs_protocol *pp, int offset,
- unsigned int hooknum, struct ip_vs_iphdr *iph);
+ struct ip_vs_protocol *pp, unsigned int toff,
+ unsigned int hooknum, struct ip_vs_iphdr *ciph);
#endif
#ifdef CONFIG_SYSCTL
@@ -2059,15 +2061,15 @@ static inline bool ip_vs_conn_use_hash2(struct ip_vs_conn *cp)
}
void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
- struct ip_vs_conn *cp, int dir);
+ struct ip_vs_conn *cp, int dir, unsigned int toff,
+ bool has_ports);
#ifdef CONFIG_IP_VS_IPV6
void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp,
- struct ip_vs_conn *cp, int dir);
+ struct ip_vs_conn *cp, int dir, unsigned int toff,
+ bool has_ports, struct ip_vs_iphdr *ciph);
#endif
-__sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset);
-
static inline __wsum ip_vs_check_diff4(__be32 old, __be32 new, __wsum oldsum)
{
__be32 diff[2] = { ~old, new };
@@ -2093,6 +2095,36 @@ static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum)
return csum_partial(diff, sizeof(diff), oldsum);
}
+static inline bool ip_vs_checksum_needed(struct sk_buff *skb, int af)
+{
+ /* Checksum unnecessary or already validated? */
+ if (skb_csum_unnecessary(skb))
+ return false;
+ /* LOCAL_OUT ? */
+ if (!skb->dev || skb->dev->flags & IFF_LOOPBACK)
+ return false;
+ /* !LOCAL_IN (FORWARD) ? */
+ if (af == AF_INET6) {
+ if (!(dst_rt6_info(skb_dst(skb))->rt6i_flags & RTF_LOCAL))
+ return false;
+ } else {
+ if (!(skb_rtable(skb)->rt_flags & RTCF_LOCAL))
+ return false;
+ }
+ return true;
+}
+
+/**
+ * ip_vs_checksum_common_check - validate checksum for TCP/UDP/ICMP
+ */
+static inline bool ip_vs_checksum_common_check(struct sk_buff *skb,
+ int offset, int proto, int af)
+{
+ if (!ip_vs_checksum_needed(skb, af))
+ return true;
+ return !nf_checksum(skb, NF_INET_LOCAL_IN, offset, proto, af);
+}
+
/* Forget current conntrack (unconfirmed) and attach notrack entry */
static inline void ip_vs_notrack(struct sk_buff *skb)
{
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index c024345c9bd862..26d6babd92fcd7 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -161,6 +161,9 @@ static inline int nf_ct_expect_related(struct nf_conntrack_expect *expect,
return nf_ct_expect_related_report(expect, 0, 0, flags);
}
+int nf_ct_expect_related_pair(struct nf_conntrack_expect *expect[],
+ unsigned int flag);
+
struct nf_conn_help;
void nf_ct_expectation_gc(struct nf_conn_help *master_help);
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 9d844354c4d956..3be612145c130c 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -1294,6 +1294,7 @@ static inline void nft_use_inc_restore(u32 *use)
* @sets: sets in the table
* @objects: stateful objects in the table
* @flowtables: flow tables in the table
+ * @objname_ht: hashtable for objects lookup by name
* @hgenerator: handle generator state
* @handle: table handle
* @use: number of chain references to this table
@@ -1313,6 +1314,7 @@ struct nft_table {
struct list_head sets;
struct list_head objects;
struct list_head flowtables;
+ struct rhltable objname_ht;
u64 hgenerator;
u64 handle;
u32 use;
@@ -1400,7 +1402,7 @@ static inline void *nft_obj_data(const struct nft_object *obj)
#define nft_expr_obj(expr) *((struct nft_object **)nft_expr_priv(expr))
struct nft_object *nft_obj_lookup(const struct net *net,
- const struct nft_table *table,
+ struct nft_table *table,
const struct nlattr *nla, u32 objtype,
u8 genmask);
diff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c
index 183e8a3ff2babd..6bcd6734769b59 100644
--- a/net/ipv4/netfilter/nf_nat_h323.c
+++ b/net/ipv4/netfilter/nf_nat_h323.c
@@ -182,6 +182,7 @@ static int nat_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,
struct nf_conntrack_expect *rtp_exp,
struct nf_conntrack_expect *rtcp_exp)
{
+ struct nf_conntrack_expect *rtp_pair[2] = { rtp_exp, rtcp_exp };
struct nf_ct_h323_master *info = nfct_help_data(ct);
int dir = CTINFO2DIR(ctinfo);
int i;
@@ -227,22 +228,13 @@ static int nat_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,
int ret;
rtp_exp->tuple.dst.u.udp.port = htons(nated_port);
- ret = nf_ct_expect_related(rtp_exp, 0);
+ rtcp_exp->tuple.dst.u.udp.port = htons(nated_port + 1);
+ ret = nf_ct_expect_related_pair(rtp_pair, 0);
if (ret == 0) {
- rtcp_exp->tuple.dst.u.udp.port =
- htons(nated_port + 1);
- ret = nf_ct_expect_related(rtcp_exp, 0);
- if (ret == 0)
- break;
- else if (ret == -EBUSY) {
- nf_ct_unexpect_related(rtp_exp);
- continue;
- } else if (ret < 0) {
- nf_ct_unexpect_related(rtp_exp);
- nated_port = 0;
- break;
- }
- } else if (ret != -EBUSY) {
+ break;
+ } else if (ret == -EBUSY) {
+ continue;
+ } else if (ret < 0) {
nated_port = 0;
break;
}
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 8231317b0f1f4b..b2d77973272d25 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -1005,7 +1005,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,
#endif
if (SET_WITH_COUNTER(set))
ip_set_init_counter(ext_counter(data, set), ext);
- if (SET_WITH_COMMENT(set))
+ if (SET_WITH_COMMENT(set) && !ext->target)
ip_set_init_comment(set, ext_comment(data, set), ext);
if (SET_WITH_SKBINFO(set))
ip_set_init_skbinfo(ext_skbinfo(data, set), ext);
diff --git a/net/netfilter/ipvs/ip_vs_app.c b/net/netfilter/ipvs/ip_vs_app.c
index b0e00be85cb12c..11cbdbaf561daf 100644
--- a/net/netfilter/ipvs/ip_vs_app.c
+++ b/net/netfilter/ipvs/ip_vs_app.c
@@ -367,7 +367,7 @@ static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff *skb,
if (skb_ensure_writable(skb, ipvsh->len + sizeof(*th)))
return 0;
- th = (struct tcphdr *)(skb_network_header(skb) + ipvsh->len);
+ th = (struct tcphdr *)(skb->data + ipvsh->len);
/*
* Remember seq number in case this pkt gets resized
@@ -443,7 +443,7 @@ static inline int app_tcp_pkt_in(struct ip_vs_conn *cp, struct sk_buff *skb,
if (skb_ensure_writable(skb, ipvsh->len + sizeof(*th)))
return 0;
- th = (struct tcphdr *)(skb_network_header(skb) + ipvsh->len);
+ th = (struct tcphdr *)(skb->data + ipvsh->len);
/*
* Remember seq number in case this pkt gets resized
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 6ed2622363f0d6..36c5cba03f5bca 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -70,25 +70,45 @@ static struct kmem_cache *ip_vs_conn_cachep __read_mostly;
* bucket or hash table
* - hash table resize works like rehash but always rehashes into new table
* - bit lock on bucket serializes all operations that modify the chain
+ * - on resize, bucket from the old table is locked before bucket from the
+ * new table
* - cp->lock protects conn fields like cp->flags, cp->dest
*/
-/* Lock conn_tab bucket for conn hash/unhash, not for rehash */
+/**
+ * conn_tab_lock - Lock conn_tab buckets for conn hash/unhash, not for rehash
+ * @t: hash table for hn0, new_tbl when new_hash=true
+ * @t2: hash table for hn1, new_tbl when new_hash2=true
+ * @cp: connection
+ * @hash_key: hash key for hn0
+ * @hash_key2: hash key for hn1
+ * @use2: using hn1 (double hashing) based on the forwarding method
+ * @new_hash: mode for hn0, hash node (true) or seek node (false)
+ * @new_hash2: mode for hn1, hash node (true) or seek node (false)
+ * @head_ret: returned head for hn0
+ * @head2_ret: returned head for hn1
+ *
+ * We support 3 modes:
+ * - seek mode for both nodes, used for unhashing
+ * - hash mode for both nodes, used for hashing
+ * - seek hn0 and hash hn1, used when forwarding method is changed
+ */
static __always_inline void
-conn_tab_lock(struct ip_vs_rht *t, struct ip_vs_conn *cp, u32 hash_key,
- u32 hash_key2, bool use2, bool new_hash,
- struct hlist_bl_head **head_ret, struct hlist_bl_head **head2_ret)
+conn_tab_lock(struct ip_vs_rht *t, struct ip_vs_rht *t2, struct ip_vs_conn *cp,
+ u32 hash_key, u32 hash_key2, bool use2, bool new_hash,
+ bool new_hash2, struct hlist_bl_head **head_ret,
+ struct hlist_bl_head **head2_ret)
{
struct hlist_bl_head *head, *head2;
u32 hash_key_new, hash_key_new2;
- struct ip_vs_rht *t2 = t;
- u32 idx, idx2;
+ int idx = 0, idx2 = 0;
+
+ /* Advance idx2 when new_hash is not set but hash_key2
+ * is for new table
+ */
+ if (new_hash2 && use2 && t != t2)
+ idx2++;
- idx = hash_key & t->mask;
- if (use2)
- idx2 = hash_key2 & t->mask;
- else
- idx2 = idx;
if (!new_hash) {
/* We need to lock the bucket in the right table */
@@ -100,46 +120,45 @@ conn_tab_lock(struct ip_vs_rht *t, struct ip_vs_conn *cp, u32 hash_key,
* both nodes in different tables, use idx/idx2
* for proper lock ordering for heads.
*/
- idx = hash_key & t->mask;
- idx |= IP_VS_RHT_TABLE_ID_MASK;
- }
- if (use2) {
- if (!ip_vs_rht_same_table(t2, hash_key2)) {
- /* It is already moved to new table */
- t2 = rcu_dereference(t2->new_tbl);
- idx2 = hash_key2 & t2->mask;
- idx2 |= IP_VS_RHT_TABLE_ID_MASK;
- }
- } else {
- idx2 = idx;
+ idx++;
}
}
+ if (use2 && !new_hash2 && !ip_vs_rht_same_table(t2, hash_key2)) {
+ /* It is already moved to new table */
+ t2 = rcu_dereference(t2->new_tbl);
+ idx2++;
+ }
+ if (!use2)
+ idx2 = idx;
head = t->buckets + (hash_key & t->mask);
head2 = use2 ? t2->buckets + (hash_key2 & t2->mask) : head;
- local_bh_disable();
- /* Do not touch seqcount, this is a safe operation */
-
- if (idx <= idx2) {
+ if (idx > idx2 || (head > head2 && idx == idx2)) {
+ hlist_bl_lock(head2);
hlist_bl_lock(head);
- if (head != head2)
- hlist_bl_lock(head2);
} else {
- hlist_bl_lock(head2);
hlist_bl_lock(head);
+ if (head != head2)
+ hlist_bl_lock(head2);
}
if (!new_hash) {
+ bool changed;
+
/* Ensure hash_key is read under lock */
hash_key_new = READ_ONCE(cp->hn0.hash_key);
- hash_key_new2 = READ_ONCE(cp->hn1.hash_key);
+ changed = hash_key != hash_key_new;
+ if (use2 && !new_hash2) {
+ hash_key_new2 = READ_ONCE(cp->hn1.hash_key);
+ changed |= hash_key2 != hash_key_new2;
+ } else {
+ hash_key_new2 = hash_key2;
+ }
/* Hash changed ? */
- if (hash_key != hash_key_new ||
- (hash_key2 != hash_key_new2 && use2)) {
+ if (changed) {
if (head != head2)
hlist_bl_unlock(head2);
hlist_bl_unlock(head);
- local_bh_enable();
hash_key = hash_key_new;
hash_key2 = hash_key_new2;
goto retry;
@@ -155,7 +174,6 @@ static inline void conn_tab_unlock(struct hlist_bl_head *head,
if (head != head2)
hlist_bl_unlock(head2);
hlist_bl_unlock(head);
- local_bh_enable();
}
static void ip_vs_conn_expire(struct timer_list *t);
@@ -268,8 +286,9 @@ static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)
use2 = false;
}
- conn_tab_lock(t, cp, hash_key, hash_key2, use2, true /* new_hash */,
- &head, &head2);
+ local_bh_disable();
+ conn_tab_lock(t, t, cp, hash_key, hash_key2, use2, true /* new_hash */,
+ true /* new_hash2 */, &head, &head2);
cp->flags |= IP_VS_CONN_F_HASHED;
WRITE_ONCE(cp->hn0.hash_key, hash_key);
@@ -280,6 +299,7 @@ static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)
hlist_bl_add_head_rcu(&cp->hn1.node, head2);
conn_tab_unlock(head, head2);
+ local_bh_enable();
ret = 1;
/* Schedule resizing if load increases */
@@ -306,18 +326,20 @@ static inline bool ip_vs_conn_unlink(struct ip_vs_conn *cp)
return refcount_dec_if_one(&cp->refcnt);
rcu_read_lock();
+ local_bh_disable();
t = rcu_dereference(ipvs->conn_tab);
hash_key = READ_ONCE(cp->hn0.hash_key);
hash_key2 = READ_ONCE(cp->hn1.hash_key);
use2 = ip_vs_conn_use_hash2(cp);
- conn_tab_lock(t, cp, hash_key, hash_key2, use2, false /* new_hash */,
- &head, &head2);
+ conn_tab_lock(t, t, cp, hash_key, hash_key2, use2, false /* new_hash */,
+ false /* new_hash2 */, &head, &head2);
if (cp->flags & IP_VS_CONN_F_HASHED) {
/* Decrease refcnt and unlink conn only if we are last user */
- if (refcount_dec_if_one(&cp->refcnt)) {
+ if (use2 == ip_vs_conn_use_hash2(cp) &&
+ refcount_dec_if_one(&cp->refcnt)) {
hlist_bl_del_rcu(&cp->hn0.node);
if (use2)
hlist_bl_del_rcu(&cp->hn1.node);
@@ -328,6 +350,7 @@ static inline bool ip_vs_conn_unlink(struct ip_vs_conn *cp)
conn_tab_unlock(head, head2);
+ local_bh_enable();
rcu_read_unlock();
return ret;
@@ -632,6 +655,7 @@ void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport)
int ntbl;
int dir;
+restart:
/* No packets from inside, so we can do it in 2 steps. */
dir = use2 ? 1 : 0;
@@ -686,6 +710,23 @@ void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport)
/* Protect the cp->flags modification */
spin_lock_bh(&cp->lock);
+ /* Recheck the forwarding method under lock */
+ if (use2 != ip_vs_conn_use_hash2(cp)) {
+ use2 = !use2;
+ if (use2) {
+ spin_unlock_bh(&cp->lock);
+ /* Restart with new use2 value */
+ goto restart;
+ }
+ if (dir) {
+ /* Not started yet, so just skip dir 1 */
+ spin_unlock_bh(&cp->lock);
+ dir--;
+ goto next_dir;
+ }
+ /* Just finish dir 0 */
+ }
+
/* Lock seqcount only for the old bucket, even if we are on new table
* because it affects the del operation, not the adding.
*/
@@ -752,6 +793,61 @@ void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport)
goto next_dir;
}
+/* Change forwarding method for hashed conn */
+static void ip_vs_conn_change_fwd_mask(struct ip_vs_conn *cp, u32 new_flags)
+{
+ struct netns_ipvs *ipvs = cp->ipvs;
+ struct hlist_bl_head *head, *head2;
+ u32 hash2, hash_key, hash_key2;
+ struct ip_vs_rht *t, *t2;
+
+ /* See ip_vs_conn_use_hash2() for reference */
+ if ((cp->flags & IP_VS_CONN_F_TEMPLATE) ||
+ /* No change in double hashing ? */
+ (IP_VS_FWD_METHOD(cp) == IP_VS_CONN_F_MASQ) ==
+ ((new_flags & IP_VS_CONN_F_FWD_MASK) == IP_VS_CONN_F_MASQ)) {
+ cp->flags = new_flags;
+ return;
+ }
+ t = rcu_dereference(ipvs->conn_tab);
+ if (ip_vs_conn_use_hash2(cp)) {
+ /* Stop double hashing */
+ hash_key = READ_ONCE(cp->hn0.hash_key);
+ hash_key2 = READ_ONCE(cp->hn1.hash_key);
+
+ conn_tab_lock(t, t, cp, hash_key, hash_key2, true /* use2 */,
+ false /* new_hash */, false /* new_hash2 */,
+ &head, &head2);
+
+ /* Keep both hash keys in same table */
+ hash_key = READ_ONCE(cp->hn0.hash_key);
+ WRITE_ONCE(cp->hn1.hash_key, hash_key);
+ hlist_bl_del_rcu(&cp->hn1.node);
+ cp->flags = new_flags;
+
+ conn_tab_unlock(head, head2);
+ } else {
+ /* Start double hashing */
+
+ hash_key = READ_ONCE(cp->hn0.hash_key);
+
+ t2 = rcu_dereference(t->new_tbl);
+ hash2 = ip_vs_conn_hashkey_conn(t2, cp, true);
+ hash_key2 = ip_vs_rht_build_hash_key(t2, hash2);
+
+ /* Change the forwarding method under locked hn0 */
+ conn_tab_lock(t, t2, cp, hash_key, hash_key2, true /* use2 */,
+ false /* new_hash */, true /* new_hash2 */,
+ &head, &head2);
+
+ WRITE_ONCE(cp->hn1.hash_key, hash_key2);
+ cp->flags = new_flags;
+ hlist_bl_add_head_rcu(&cp->hn1.node, head2);
+
+ conn_tab_unlock(head, head2);
+ }
+}
+
/* Get default load factor to map conn_count/u_thresh to t->size */
static int ip_vs_conn_default_load_factor(struct netns_ipvs *ipvs)
{
@@ -1014,6 +1110,9 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
flags = cp->flags;
/* Bind with the destination and its corresponding transmitter */
if (flags & IP_VS_CONN_F_SYNC) {
+ /* Synced conns are hashed, so they can not get this flag */
+ conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
+
/* if the connection is not template and is created
* by sync, preserve the activity flag.
*/
@@ -1021,9 +1120,18 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
conn_flags &= ~IP_VS_CONN_F_INACTIVE;
/* connections inherit forwarding method from dest */
flags &= ~(IP_VS_CONN_F_FWD_MASK | IP_VS_CONN_F_NOOUTPUT);
+ flags |= conn_flags;
+ /* Changing forwarding method for hashed conn can
+ * happen only under locks
+ */
+ if (cp->flags & IP_VS_CONN_F_HASHED)
+ ip_vs_conn_change_fwd_mask(cp, flags);
+ else
+ cp->flags = flags;
+ } else {
+ flags |= conn_flags;
+ cp->flags = flags;
}
- flags |= conn_flags;
- cp->flags = flags;
cp->dest = dest;
IP_VS_DBG_BUF(7, "Bind-dest %s c:%s:%d v:%s:%d "
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index bafab93451d037..6b79e0c4d9e284 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -867,7 +867,7 @@ static int sysctl_nat_icmp_send(struct netns_ipvs *ipvs) { return 0; }
#endif
-__sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset)
+static __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset)
{
return csum_fold(skb_checksum(skb, offset, skb->len - offset, 0));
}
@@ -924,13 +924,13 @@ static int ip_vs_route_me_harder(struct netns_ipvs *ipvs, int af,
* - inout: 1=in->out, 0=out->in
*/
void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
- struct ip_vs_conn *cp, int inout)
+ struct ip_vs_conn *cp, int inout, unsigned int toff,
+ bool has_ports)
{
struct iphdr *iph = ip_hdr(skb);
- unsigned int icmp_offset = iph->ihl*4;
- struct icmphdr *icmph = (struct icmphdr *)(skb_network_header(skb) +
- icmp_offset);
+ struct icmphdr *icmph = (struct icmphdr *)(skb->data + toff);
struct iphdr *ciph = (struct iphdr *)(icmph + 1);
+ unsigned int coff __maybe_unused = toff + sizeof(struct icmphdr);
if (inout) {
iph->saddr = cp->vaddr.ip;
@@ -945,8 +945,7 @@ void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
}
/* the TCP/UDP/SCTP port */
- if (IPPROTO_TCP == ciph->protocol || IPPROTO_UDP == ciph->protocol ||
- IPPROTO_SCTP == ciph->protocol) {
+ if (has_ports) {
__be16 *ports = (void *)ciph + ciph->ihl*4;
if (inout)
@@ -957,48 +956,40 @@ void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
/* And finally the ICMP checksum */
icmph->checksum = 0;
- icmph->checksum = ip_vs_checksum_complete(skb, icmp_offset);
+ icmph->checksum = ip_vs_checksum_complete(skb, toff);
skb->ip_summed = CHECKSUM_UNNECESSARY;
if (inout)
- IP_VS_DBG_PKT(11, AF_INET, pp, skb, (void *)ciph - (void *)iph,
- "Forwarding altered outgoing ICMP");
+ IP_VS_DBG_PKT(11, AF_INET, pp, skb, coff,
+ "Forwarding altered outgoing ICMP");
else
- IP_VS_DBG_PKT(11, AF_INET, pp, skb, (void *)ciph - (void *)iph,
- "Forwarding altered incoming ICMP");
+ IP_VS_DBG_PKT(11, AF_INET, pp, skb, coff,
+ "Forwarding altered incoming ICMP");
}
#ifdef CONFIG_IP_VS_IPV6
void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp,
- struct ip_vs_conn *cp, int inout)
+ struct ip_vs_conn *cp, int inout, unsigned int toff,
+ bool has_ports, struct ip_vs_iphdr *ciph)
{
struct ipv6hdr *iph = ipv6_hdr(skb);
- unsigned int icmp_offset = 0;
- unsigned int offs = 0; /* header offset*/
- int protocol;
struct icmp6hdr *icmph;
- struct ipv6hdr *ciph;
- unsigned short fragoffs;
+ struct ipv6hdr *cih;
- ipv6_find_hdr(skb, &icmp_offset, IPPROTO_ICMPV6, &fragoffs, NULL);
- icmph = (struct icmp6hdr *)(skb_network_header(skb) + icmp_offset);
- offs = icmp_offset + sizeof(struct icmp6hdr);
- ciph = (struct ipv6hdr *)(skb_network_header(skb) + offs);
-
- protocol = ipv6_find_hdr(skb, &offs, -1, &fragoffs, NULL);
+ icmph = (struct icmp6hdr *)(skb->data + toff);
+ cih = (struct ipv6hdr *)(skb->data + ciph->off);
if (inout) {
iph->saddr = cp->vaddr.in6;
- ciph->daddr = cp->vaddr.in6;
+ cih->daddr = cp->vaddr.in6;
} else {
iph->daddr = cp->daddr.in6;
- ciph->saddr = cp->daddr.in6;
+ cih->saddr = cp->daddr.in6;
}
/* the TCP/UDP/SCTP port */
- if (!fragoffs && (IPPROTO_TCP == protocol || IPPROTO_UDP == protocol ||
- IPPROTO_SCTP == protocol)) {
- __be16 *ports = (void *)(skb_network_header(skb) + offs);
+ if (has_ports) {
+ __be16 *ports = (void *)(skb->data + ciph->len);
IP_VS_DBG(11, "%s() changed port %d to %d\n", __func__,
ntohs(inout ? ports[1] : ports[0]),
@@ -1011,19 +1002,17 @@ void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp,
/* And finally the ICMP checksum */
icmph->icmp6_cksum = ~csum_ipv6_magic(&iph->saddr, &iph->daddr,
- skb->len - icmp_offset,
+ skb->len - toff,
IPPROTO_ICMPV6, 0);
- skb->csum_start = skb_network_header(skb) - skb->head + icmp_offset;
+ skb->csum_start = skb_headroom(skb) + toff;
skb->csum_offset = offsetof(struct icmp6hdr, icmp6_cksum);
skb->ip_summed = CHECKSUM_PARTIAL;
if (inout)
- IP_VS_DBG_PKT(11, AF_INET6, pp, skb,
- (void *)ciph - (void *)iph,
+ IP_VS_DBG_PKT(11, AF_INET6, pp, skb, ciph->off,
"Forwarding altered outgoing ICMPv6");
else
- IP_VS_DBG_PKT(11, AF_INET6, pp, skb,
- (void *)ciph - (void *)iph,
+ IP_VS_DBG_PKT(11, AF_INET6, pp, skb, ciph->off,
"Forwarding altered incoming ICMPv6");
}
#endif
@@ -1033,36 +1022,41 @@ void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp,
*/
static int handle_response_icmp(int af, struct sk_buff *skb,
union nf_inet_addr *snet,
- __u8 protocol, struct ip_vs_conn *cp,
+ struct ip_vs_conn *cp,
struct ip_vs_protocol *pp,
- unsigned int offset, unsigned int ihl,
- unsigned int hooknum)
+ struct ip_vs_iphdr *ciph,
+ unsigned int toff, unsigned int hooknum)
{
+ int iproto = af == AF_INET6 ? IPPROTO_ICMPV6 : IPPROTO_ICMP;
unsigned int verdict = NF_DROP;
+ unsigned int ctoff = ciph->len;
+ bool has_ports = false;
if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)
goto after_nat;
/* Ensure the checksum is correct */
- if (!skb_csum_unnecessary(skb) && ip_vs_checksum_complete(skb, ihl)) {
+ if (!ip_vs_checksum_common_check(skb, toff, iproto, af)) {
/* Failed checksum! */
IP_VS_DBG_BUF(1, "Forward ICMP: failed checksum from %s!\n",
IP_VS_DBG_ADDR(af, snet));
goto out;
}
- if (IPPROTO_TCP == protocol || IPPROTO_UDP == protocol ||
- IPPROTO_SCTP == protocol)
- offset += 2 * sizeof(__u16);
- if (skb_ensure_writable(skb, offset))
+ if (ciph->protocol == IPPROTO_TCP || ciph->protocol == IPPROTO_UDP ||
+ ciph->protocol == IPPROTO_SCTP) {
+ ctoff += 2 * sizeof(__u16);
+ has_ports = true;
+ }
+ if (skb_ensure_writable(skb, ctoff))
goto out;
#ifdef CONFIG_IP_VS_IPV6
if (af == AF_INET6)
- ip_vs_nat_icmp_v6(skb, pp, cp, 1);
+ ip_vs_nat_icmp_v6(skb, pp, cp, 1, toff, has_ports, ciph);
else
#endif
- ip_vs_nat_icmp(skb, pp, cp, 1);
+ ip_vs_nat_icmp(skb, pp, cp, 1, toff, has_ports);
if (ip_vs_route_me_harder(cp->ipvs, af, skb, hooknum))
goto out;
@@ -1090,9 +1084,9 @@ static int handle_response_icmp(int af, struct sk_buff *skb,
* Currently handles error types - unreachable, quench, ttl exceeded.
*/
static int ip_vs_out_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb,
- int *related, unsigned int hooknum)
+ int *related, unsigned int hooknum,
+ struct ip_vs_iphdr *ipvsh)
{
- struct iphdr *iph;
struct icmphdr _icmph, *ic;
struct iphdr _ciph, *cih; /* The ip header contained within the ICMP */
struct ip_vs_iphdr ciph;
@@ -1107,17 +1101,19 @@ static int ip_vs_out_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb,
if (ip_is_fragment(ip_hdr(skb))) {
if (ip_vs_gather_frags(ipvs, skb, ip_vs_defrag_user(hooknum)))
return NF_STOLEN;
+ if (!ip_vs_fill_iph_skb(AF_INET, skb, false, ipvsh))
+ return NF_ACCEPT;
}
- iph = ip_hdr(skb);
- offset = ihl = iph->ihl * 4;
+ ihl = ipvsh->len;
+ offset = ipvsh->len;
ic = skb_header_pointer(skb, offset, sizeof(_icmph), &_icmph);
if (ic == NULL)
return NF_DROP;
IP_VS_DBG(12, "Outgoing ICMP (%d,%d) %pI4->%pI4\n",
ic->type, ntohs(icmp_id(ic)),
- &iph->saddr, &iph->daddr);
+ &ipvsh->saddr.ip, &ipvsh->daddr.ip);
/*
* Work through seeing if this is for us.
@@ -1136,7 +1132,7 @@ static int ip_vs_out_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb,
/* Now find the contained IP header */
offset += sizeof(_icmph);
cih = skb_header_pointer(skb, offset, sizeof(_ciph), &_ciph);
- if (cih == NULL)
+ if (!(cih && cih->version == 4 && cih->ihl >= 5))
return NF_ACCEPT; /* The packet looks wrong, ignore */
pp = ip_vs_proto_get(cih->protocol);
@@ -1144,8 +1140,7 @@ static int ip_vs_out_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb,
return NF_ACCEPT;
/* Is the embedded protocol header present? */
- if (unlikely(cih->frag_off & htons(IP_OFFSET) &&
- pp->dont_defrag))
+ if (unlikely(cih->frag_off & htons(IP_OFFSET) && !pp->dont_defrag))
return NF_ACCEPT;
IP_VS_DBG_PKT(11, AF_INET, pp, skb, offset,
@@ -1159,9 +1154,9 @@ static int ip_vs_out_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb,
if (!cp)
return NF_ACCEPT;
- snet.ip = iph->saddr;
- return handle_response_icmp(AF_INET, skb, &snet, cih->protocol, cp,
- pp, ciph.len, ihl, hooknum);
+ snet.ip = ipvsh->saddr.ip;
+ return handle_response_icmp(AF_INET, skb, &snet, cp, pp, &ciph, ihl,
+ hooknum);
}
#ifdef CONFIG_IP_VS_IPV6
@@ -1174,7 +1169,6 @@ static int ip_vs_out_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,
struct ip_vs_conn *cp;
struct ip_vs_protocol *pp;
union nf_inet_addr snet;
- unsigned int offset;
*related = 1;
ic = frag_safe_skb_hp(skb, ipvsh->len, sizeof(_icmph), &_icmph);
@@ -1210,6 +1204,10 @@ static int ip_vs_out_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,
if (!pp)
return NF_ACCEPT;
+ /* Is the embedded protocol header present? */
+ if (unlikely(ciph.fragoffs && !pp->dont_defrag))
+ return NF_ACCEPT;
+
/* The embedded headers contain source and dest in reverse order */
cp = INDIRECT_CALL_1(pp->conn_out_get, ip_vs_conn_out_get_proto,
ipvs, AF_INET6, skb, &ciph);
@@ -1217,9 +1215,8 @@ static int ip_vs_out_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,
return NF_ACCEPT;
snet.in6 = ciph.saddr.in6;
- offset = ciph.len;
- return handle_response_icmp(AF_INET6, skb, &snet, ciph.protocol, cp,
- pp, offset, ipvsh->len, hooknum);
+ return handle_response_icmp(AF_INET6, skb, &snet, cp, pp, &ciph,
+ ipvsh->len, hooknum);
}
#endif
@@ -1545,7 +1542,8 @@ ip_vs_out_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *stat
#endif
if (unlikely(iph.protocol == IPPROTO_ICMP)) {
int related;
- int verdict = ip_vs_out_icmp(ipvs, skb, &related, hooknum);
+ int verdict = ip_vs_out_icmp(ipvs, skb, &related,
+ hooknum, &iph);
if (related)
return verdict;
@@ -1753,9 +1751,8 @@ static int ipvs_gre_decap(struct netns_ipvs *ipvs, struct sk_buff *skb,
*/
static int
ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,
- unsigned int hooknum)
+ unsigned int hooknum, struct ip_vs_iphdr *iph)
{
- struct iphdr *iph;
struct icmphdr _icmph, *ic;
struct iphdr _ciph, *cih; /* The ip header contained within the ICMP */
struct ip_vs_iphdr ciph;
@@ -1765,7 +1762,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,
unsigned int offset, offset2, ihl, verdict;
bool tunnel, new_cp = false;
union nf_inet_addr *raddr;
- char *outer_proto = "IPIP";
+ char *outer_proto __maybe_unused = "IPIP";
unsigned int hlen_ipip;
int ulen = 0;
@@ -1775,17 +1772,19 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,
if (ip_is_fragment(ip_hdr(skb))) {
if (ip_vs_gather_frags(ipvs, skb, ip_vs_defrag_user(hooknum)))
return NF_STOLEN;
+ if (!ip_vs_fill_iph_skb(AF_INET, skb, false, iph))
+ return NF_ACCEPT;
}
- iph = ip_hdr(skb);
- offset = ihl = iph->ihl * 4;
+ ihl = iph->len;
+ offset = iph->len;
ic = skb_header_pointer(skb, offset, sizeof(_icmph), &_icmph);
if (ic == NULL)
return NF_DROP;
IP_VS_DBG(12, "Incoming ICMP (%d,%d) %pI4->%pI4\n",
ic->type, ntohs(icmp_id(ic)),
- &iph->saddr, &iph->daddr);
+ &iph->saddr.ip, &iph->daddr.ip);
/*
* Work through seeing if this is for us.
@@ -1867,8 +1866,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,
pp = pd->pp;
/* Is the embedded protocol header present? */
- if (unlikely(cih->frag_off & htons(IP_OFFSET) &&
- pp->dont_defrag))
+ if (unlikely(cih->frag_off & htons(IP_OFFSET) && !pp->dont_defrag))
return NF_ACCEPT;
IP_VS_DBG_PKT(11, AF_INET, pp, skb, offset,
@@ -1876,7 +1874,6 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,
offset2 = offset;
ip_vs_fill_iph_skb_icmp(AF_INET, skb, offset, !tunnel, &ciph);
- offset = ciph.len;
/* The embedded headers contain source and dest in reverse order.
* For IPIP/UDP/GRE tunnel this is error for request, not for reply.
@@ -1898,10 +1895,11 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,
verdict = NF_DROP;
/* Ensure the checksum is correct */
- if (!skb_csum_unnecessary(skb) && ip_vs_checksum_complete(skb, ihl)) {
+ if ((IP_VS_FWD_METHOD(cp) == IP_VS_CONN_F_MASQ || tunnel) &&
+ !ip_vs_checksum_common_check(skb, ihl, IPPROTO_ICMP, AF_INET)) {
/* Failed checksum! */
IP_VS_DBG(1, "Incoming ICMP: failed checksum from %pI4!\n",
- &iph->saddr);
+ &iph->saddr.ip);
goto out;
}
@@ -1969,10 +1967,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,
/* do the statistics and put it back */
ip_vs_in_stats(cp, skb);
- if (IPPROTO_TCP == cih->protocol || IPPROTO_UDP == cih->protocol ||
- IPPROTO_SCTP == cih->protocol)
- offset += 2 * sizeof(__u16);
- verdict = ip_vs_icmp_xmit(skb, cp, pp, offset, hooknum, &ciph);
+ verdict = ip_vs_icmp_xmit(skb, cp, pp, iph->len, hooknum, &ciph);
out:
if (likely(!new_cp))
@@ -2032,8 +2027,8 @@ static int ip_vs_in_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,
return NF_ACCEPT;
pp = pd->pp;
- /* Cannot handle fragmented embedded protocol */
- if (ciph.fragoffs)
+ /* Is the embedded protocol header present? */
+ if (ciph.fragoffs && !pp->dont_defrag)
return NF_ACCEPT;
IP_VS_DBG_PKT(11, AF_INET6, pp, skb, offset,
@@ -2057,23 +2052,22 @@ static int ip_vs_in_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,
new_cp = true;
}
- /* VS/TUN, VS/DR and LOCALNODE just let it go */
- if ((hooknum == NF_INET_LOCAL_OUT) &&
- (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)) {
- verdict = NF_ACCEPT;
+ verdict = NF_DROP;
+
+ /* Ensure the checksum is correct */
+ if (IP_VS_FWD_METHOD(cp) == IP_VS_CONN_F_MASQ &&
+ !ip_vs_checksum_common_check(skb, iph->len, IPPROTO_ICMPV6,
+ AF_INET6)) {
+ /* Failed checksum! */
+ IP_VS_DBG(1, "Incoming ICMPv6: failed checksum from %pI6c!\n",
+ &iph->saddr);
goto out;
}
/* do the statistics and put it back */
ip_vs_in_stats(cp, skb);
- /* Need to mangle contained IPv6 header in ICMPv6 packet */
- offset = ciph.len;
- if (IPPROTO_TCP == ciph.protocol || IPPROTO_UDP == ciph.protocol ||
- IPPROTO_SCTP == ciph.protocol)
- offset += 2 * sizeof(__u16); /* Also mangle ports */
-
- verdict = ip_vs_icmp_xmit_v6(skb, cp, pp, offset, hooknum, &ciph);
+ verdict = ip_vs_icmp_xmit_v6(skb, cp, pp, iph->len, hooknum, &ciph);
out:
if (likely(!new_cp))
@@ -2152,7 +2146,7 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *state
if (unlikely(iph.protocol == IPPROTO_ICMP)) {
int related;
int verdict = ip_vs_in_icmp(ipvs, skb, &related,
- hooknum);
+ hooknum, &iph);
if (related)
return verdict;
@@ -2200,8 +2194,11 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *state
}
if (resched) {
- if (!old_ct)
+ if (!old_ct) {
+ spin_lock_bh(&cp->lock);
cp->flags &= ~IP_VS_CONN_F_NFCT;
+ spin_unlock_bh(&cp->lock);
+ }
if (!atomic_read(&cp->n_control))
ip_vs_conn_expire_now(cp);
__ip_vs_conn_put(cp);
@@ -2217,8 +2214,11 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *state
if (sysctl_expire_nodest_conn(ipvs)) {
bool old_ct = ip_vs_conn_uses_old_conntrack(cp, skb);
- if (!old_ct)
+ if (!old_ct) {
+ spin_lock_bh(&cp->lock);
cp->flags &= ~IP_VS_CONN_F_NFCT;
+ spin_unlock_bh(&cp->lock);
+ }
ip_vs_conn_expire_now(cp);
__ip_vs_conn_put(cp);
@@ -2288,6 +2288,7 @@ ip_vs_forward_icmp(void *priv, struct sk_buff *skb,
const struct nf_hook_state *state)
{
struct netns_ipvs *ipvs = net_ipvs(state->net);
+ struct ip_vs_iphdr iphdr;
int r;
/* ipvs enabled in this netns ? */
@@ -2297,10 +2298,9 @@ ip_vs_forward_icmp(void *priv, struct sk_buff *skb,
if (state->pf == NFPROTO_IPV4) {
if (ip_hdr(skb)->protocol != IPPROTO_ICMP)
return NF_ACCEPT;
+ ip_vs_fill_iph_skb(AF_INET, skb, false, &iphdr);
#ifdef CONFIG_IP_VS_IPV6
} else {
- struct ip_vs_iphdr iphdr;
-
ip_vs_fill_iph_skb(AF_INET6, skb, false, &iphdr);
if (iphdr.protocol != IPPROTO_ICMPV6)
@@ -2310,7 +2310,7 @@ ip_vs_forward_icmp(void *priv, struct sk_buff *skb,
#endif
}
- return ip_vs_in_icmp(ipvs, skb, &r, state->hook);
+ return ip_vs_in_icmp(ipvs, skb, &r, state->hook, &iphdr);
}
static const struct nf_hook_ops ip_vs_ops4[] = {
diff --git a/net/netfilter/ipvs/ip_vs_proto_sctp.c b/net/netfilter/ipvs/ip_vs_proto_sctp.c
index c67317be17dfaf..3dbd3096e1637b 100644
--- a/net/netfilter/ipvs/ip_vs_proto_sctp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_sctp.c
@@ -11,7 +11,7 @@
static int
sctp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,
- unsigned int sctphoff);
+ struct ip_vs_iphdr *iph);
static int
sctp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
@@ -109,7 +109,7 @@ sctp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
int ret;
/* Some checks before mangling */
- if (!sctp_csum_check(cp->af, skb, pp, sctphoff))
+ if (!sctp_csum_check(cp->af, skb, pp, iph))
return 0;
/* Call application helper if needed */
@@ -121,7 +121,7 @@ sctp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
payload_csum = true;
}
- sctph = (void *) skb_network_header(skb) + sctphoff;
+ sctph = (void *)skb->data + sctphoff;
/* Only update csum if we really have to */
if (sctph->source != cp->vport || payload_csum ||
@@ -157,7 +157,7 @@ sctp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
int ret;
/* Some checks before mangling */
- if (!sctp_csum_check(cp->af, skb, pp, sctphoff))
+ if (!sctp_csum_check(cp->af, skb, pp, iph))
return 0;
/* Call application helper if needed */
@@ -169,7 +169,7 @@ sctp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
payload_csum = true;
}
- sctph = (void *) skb_network_header(skb) + sctphoff;
+ sctph = (void *)skb->data + sctphoff;
/* Only update csum if we really have to */
if (sctph->dest != cp->dport || payload_csum ||
@@ -187,19 +187,22 @@ sctp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
static int
sctp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,
- unsigned int sctphoff)
+ struct ip_vs_iphdr *iph)
{
+ unsigned int sctphoff = iph->len;
struct sctphdr *sh;
__le32 cmp, val;
+ if (!ip_vs_checksum_needed(skb, af))
+ return 1;
sh = (struct sctphdr *)(skb->data + sctphoff);
cmp = sh->checksum;
val = sctp_compute_cksum(skb, sctphoff);
if (val != cmp) {
/* CRC failure, dump it. */
- IP_VS_DBG_RL_PKT(0, af, pp, skb, 0,
- "Failed checksum for");
+ IP_VS_DBG_RL_PKT(0, af, pp, skb, iph->off,
+ "Failed checksum for");
return 0;
}
return 1;
diff --git a/net/netfilter/ipvs/ip_vs_proto_tcp.c b/net/netfilter/ipvs/ip_vs_proto_tcp.c
index f86b763efcc4dc..99a286fdc90c65 100644
--- a/net/netfilter/ipvs/ip_vs_proto_tcp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_tcp.c
@@ -29,7 +29,7 @@
static int
tcp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,
- unsigned int tcphoff);
+ struct ip_vs_iphdr *iph);
static int
tcp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
@@ -166,7 +166,7 @@ tcp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
int ret;
/* Some checks before mangling */
- if (!tcp_csum_check(cp->af, skb, pp, tcphoff))
+ if (!tcp_csum_check(cp->af, skb, pp, iph))
return 0;
/* Call application helper if needed */
@@ -179,7 +179,7 @@ tcp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
payload_csum = true;
}
- tcph = (void *)skb_network_header(skb) + tcphoff;
+ tcph = (void *)skb->data + tcphoff;
tcph->source = cp->vport;
/* Adjust TCP checksums */
@@ -244,7 +244,7 @@ tcp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
int ret;
/* Some checks before mangling */
- if (!tcp_csum_check(cp->af, skb, pp, tcphoff))
+ if (!tcp_csum_check(cp->af, skb, pp, iph))
return 0;
/*
@@ -260,7 +260,7 @@ tcp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
payload_csum = true;
}
- tcph = (void *)skb_network_header(skb) + tcphoff;
+ tcph = (void *)skb->data + tcphoff;
tcph->dest = cp->dport;
/*
@@ -302,41 +302,13 @@ tcp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
static int
tcp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,
- unsigned int tcphoff)
+ struct ip_vs_iphdr *iph)
{
- switch (skb->ip_summed) {
- case CHECKSUM_NONE:
- skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0);
- fallthrough;
- case CHECKSUM_COMPLETE:
-#ifdef CONFIG_IP_VS_IPV6
- if (af == AF_INET6) {
- if (csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
- &ipv6_hdr(skb)->daddr,
- skb->len - tcphoff,
- IPPROTO_TCP,
- skb->csum)) {
- IP_VS_DBG_RL_PKT(0, af, pp, skb, 0,
- "Failed checksum for");
- return 0;
- }
- } else
-#endif
- if (csum_tcpudp_magic(ip_hdr(skb)->saddr,
- ip_hdr(skb)->daddr,
- skb->len - tcphoff,
- ip_hdr(skb)->protocol,
- skb->csum)) {
- IP_VS_DBG_RL_PKT(0, af, pp, skb, 0,
- "Failed checksum for");
- return 0;
- }
- break;
- default:
- /* No need to checksum. */
- break;
+ if (!ip_vs_checksum_common_check(skb, iph->len, IPPROTO_TCP, af)) {
+ IP_VS_DBG_RL_PKT(0, af, pp, skb, iph->off,
+ "Failed checksum for");
+ return 0;
}
-
return 1;
}
diff --git a/net/netfilter/ipvs/ip_vs_proto_udp.c b/net/netfilter/ipvs/ip_vs_proto_udp.c
index 58f9e255927e2e..f32785682402dd 100644
--- a/net/netfilter/ipvs/ip_vs_proto_udp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_udp.c
@@ -25,7 +25,7 @@
static int
udp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,
- unsigned int udphoff);
+ struct ip_vs_iphdr *iph);
static int
udp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
@@ -155,7 +155,7 @@ udp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
int ret;
/* Some checks before mangling */
- if (!udp_csum_check(cp->af, skb, pp, udphoff))
+ if (!udp_csum_check(cp->af, skb, pp, iph))
return 0;
/*
@@ -170,7 +170,7 @@ udp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
payload_csum = true;
}
- udph = (void *)skb_network_header(skb) + udphoff;
+ udph = (void *)skb->data + udphoff;
udph->source = cp->vport;
/*
@@ -238,7 +238,7 @@ udp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
int ret;
/* Some checks before mangling */
- if (!udp_csum_check(cp->af, skb, pp, udphoff))
+ if (!udp_csum_check(cp->af, skb, pp, iph))
return 0;
/*
@@ -254,7 +254,7 @@ udp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
payload_csum = true;
}
- udph = (void *)skb_network_header(skb) + udphoff;
+ udph = (void *)skb->data + udphoff;
udph->dest = cp->dport;
/*
@@ -298,48 +298,20 @@ udp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
static int
udp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp,
- unsigned int udphoff)
+ struct ip_vs_iphdr *iph)
{
struct udphdr _udph, *uh;
- uh = skb_header_pointer(skb, udphoff, sizeof(_udph), &_udph);
+ uh = skb_header_pointer(skb, iph->len, sizeof(_udph), &_udph);
if (uh == NULL)
return 0;
- if (uh->check != 0) {
- switch (skb->ip_summed) {
- case CHECKSUM_NONE:
- skb->csum = skb_checksum(skb, udphoff,
- skb->len - udphoff, 0);
- fallthrough;
- case CHECKSUM_COMPLETE:
-#ifdef CONFIG_IP_VS_IPV6
- if (af == AF_INET6) {
- if (csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
- &ipv6_hdr(skb)->daddr,
- skb->len - udphoff,
- IPPROTO_UDP,
- skb->csum)) {
- IP_VS_DBG_RL_PKT(0, af, pp, skb, 0,
- "Failed checksum for");
- return 0;
- }
- } else
-#endif
- if (csum_tcpudp_magic(ip_hdr(skb)->saddr,
- ip_hdr(skb)->daddr,
- skb->len - udphoff,
- ip_hdr(skb)->protocol,
- skb->csum)) {
- IP_VS_DBG_RL_PKT(0, af, pp, skb, 0,
- "Failed checksum for");
- return 0;
- }
- break;
- default:
- /* No need to checksum. */
- break;
- }
+ if (!uh->check)
+ return 1;
+ if (!ip_vs_checksum_common_check(skb, iph->len, IPPROTO_UDP, af)) {
+ IP_VS_DBG_RL_PKT(0, af, pp, skb, iph->off,
+ "Failed checksum for");
+ return 0;
}
return 1;
}
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 9fef4335da13fd..0b0c5304993a91 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -1502,20 +1502,22 @@ ip_vs_dr_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
*/
int
ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
- struct ip_vs_protocol *pp, int offset, unsigned int hooknum,
- struct ip_vs_iphdr *iph)
+ struct ip_vs_protocol *pp, unsigned int toff,
+ unsigned int hooknum, struct ip_vs_iphdr *ciph)
{
struct rtable *rt; /* Route to the other host */
int rc;
int local;
int rt_mode, was_input;
+ bool has_ports = false;
+ unsigned int wlen;
/* The ICMP packet for VS/TUN, VS/DR and LOCALNODE will be
forwarded directly here, because there is no need to
translate address/port back */
if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ) {
if (cp->packet_xmit)
- rc = cp->packet_xmit(skb, cp, pp, iph);
+ rc = cp->packet_xmit(skb, cp, pp, ciph);
else
rc = NF_ACCEPT;
/* do not touch skb anymore */
@@ -1533,7 +1535,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
IP_VS_RT_MODE_LOCAL | IP_VS_RT_MODE_NON_LOCAL |
IP_VS_RT_MODE_RDR : IP_VS_RT_MODE_NON_LOCAL;
local = __ip_vs_get_out_rt(cp->ipvs, cp->af, skb, cp->dest, cp->daddr.ip, rt_mode,
- NULL, iph);
+ NULL, ciph);
if (local < 0)
goto tx_error;
rt = skb_rtable(skb);
@@ -1564,14 +1566,21 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
goto tx_error;
}
+ wlen = ciph->len;
+ if (ciph->protocol == IPPROTO_TCP || ciph->protocol == IPPROTO_UDP ||
+ ciph->protocol == IPPROTO_SCTP) {
+ wlen += 2 * sizeof(__u16); /* Also mangle ports */
+ has_ports = true;
+ }
+
/* copy-on-write the packet before mangling it */
- if (skb_ensure_writable(skb, offset))
+ if (skb_ensure_writable(skb, wlen))
goto tx_error;
if (skb_cow(skb, rt->dst.dev->hard_header_len))
goto tx_error;
- ip_vs_nat_icmp(skb, pp, cp, 0);
+ ip_vs_nat_icmp(skb, pp, cp, 0, toff, has_ports);
/* Another hack: avoid icmp_send in ip_fragment */
skb->ignore_df = 1;
@@ -1587,10 +1596,12 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
#ifdef CONFIG_IP_VS_IPV6
int
ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
- struct ip_vs_protocol *pp, int offset, unsigned int hooknum,
- struct ip_vs_iphdr *ipvsh)
+ struct ip_vs_protocol *pp, unsigned int toff,
+ unsigned int hooknum, struct ip_vs_iphdr *ciph)
{
+ bool has_ports = false;
struct rt6_info *rt; /* Route to the other host */
+ unsigned int wlen;
int rc;
int local;
int rt_mode;
@@ -1600,7 +1611,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
translate address/port back */
if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ) {
if (cp->packet_xmit)
- rc = cp->packet_xmit(skb, cp, pp, ipvsh);
+ rc = cp->packet_xmit(skb, cp, pp, ciph);
else
rc = NF_ACCEPT;
/* do not touch skb anymore */
@@ -1617,7 +1628,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
IP_VS_RT_MODE_LOCAL | IP_VS_RT_MODE_NON_LOCAL |
IP_VS_RT_MODE_RDR : IP_VS_RT_MODE_NON_LOCAL;
local = __ip_vs_get_out_rt_v6(cp->ipvs, cp->af, skb, cp->dest,
- &cp->daddr.in6, NULL, ipvsh, 0, rt_mode);
+ &cp->daddr.in6, NULL, ciph, 0, rt_mode);
if (local < 0)
goto tx_error;
rt = dst_rt6_info(skb_dst(skb));
@@ -1648,14 +1659,21 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
goto tx_error;
}
+ wlen = ciph->len;
+ if (ciph->protocol == IPPROTO_TCP || ciph->protocol == IPPROTO_UDP ||
+ ciph->protocol == IPPROTO_SCTP) {
+ wlen += 2 * sizeof(__u16); /* Also mangle ports */
+ has_ports = true;
+ }
+
/* copy-on-write the packet before mangling it */
- if (skb_ensure_writable(skb, offset))
+ if (skb_ensure_writable(skb, wlen))
goto tx_error;
if (skb_cow(skb, rt->dst.dev->hard_header_len))
goto tx_error;
- ip_vs_nat_icmp_v6(skb, pp, cp, 0);
+ ip_vs_nat_icmp_v6(skb, pp, cp, 0, toff, has_ports, ciph);
/* Another hack: avoid icmp_send in ip_fragment */
skb->ignore_df = 1;
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
index 7ae68d60586a23..8a3b9e33e94f77 100644
--- a/net/netfilter/nf_conntrack_expect.c
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -427,7 +427,6 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp,
exp->timeout += helper->expect_policy[exp->class].timeout * HZ;
hlist_add_head_rcu(&exp->lnode, &master_help->expectations);
- master_help->expecting[exp->class]++;
hlist_add_head_rcu(&exp->hnode, &nf_ct_expect_hash[h]);
cnet = nf_ct_pernet(net);
@@ -534,6 +533,7 @@ int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,
if (ret < 0)
goto out;
+ master_help->expecting[expect->class]++;
nf_ct_expect_insert(expect, master_help);
nf_ct_expect_event_report(IPEXP_NEW, expect, portid, report);
@@ -546,6 +546,39 @@ int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,
}
EXPORT_SYMBOL_GPL(nf_ct_expect_related_report);
+int nf_ct_expect_related_pair(struct nf_conntrack_expect *expect[],
+ unsigned int flags)
+{
+ struct nf_conn_help *master_help;
+ int i, ret;
+
+ spin_lock_bh(&nf_conntrack_expect_lock);
+ master_help = nfct_help(expect[0]->master);
+ if (!master_help || master_help != nfct_help(expect[1]->master)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ for (i = 0; i < 2; i++) {
+ ret = __nf_ct_expect_check(expect[i], master_help, flags);
+ if (ret < 0) {
+ if (i == 1)
+ master_help->expecting[expect[0]->class]--;
+ goto out;
+ }
+ master_help->expecting[expect[i]->class]++;
+ }
+
+ for (i = 0; i < 2; i++) {
+ nf_ct_expect_insert(expect[i], master_help);
+ nf_ct_expect_event_report(IPEXP_NEW, expect[i], 0, 0);
+ }
+out:
+ spin_unlock_bh(&nf_conntrack_expect_lock);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(nf_ct_expect_related_pair);
+
void nf_ct_expect_iterate_destroy(bool (*iter)(struct nf_conntrack_expect *e, void *data),
void *data)
{
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index f3f90a86633894..e4a70d1d77b0b9 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -1663,7 +1663,7 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff,
unsigned int matchoff, matchlen;
unsigned int msglen, origlen;
const char *dptr, *end;
- s16 diff, tdiff = 0;
+ s32 diff, tdiff = 0;
int ret = NF_ACCEPT;
unsigned long clen;
bool term;
diff --git a/net/netfilter/nf_nat_sip.c b/net/netfilter/nf_nat_sip.c
index aea02f6aff092a..133bd713fe0c29 100644
--- a/net/netfilter/nf_nat_sip.c
+++ b/net/netfilter/nf_nat_sip.c
@@ -321,7 +321,7 @@ static unsigned int nf_nat_sip(struct sk_buff *skb, unsigned int protoff,
}
static void nf_nat_sip_seq_adjust(struct sk_buff *skb, unsigned int protoff,
- s16 off)
+ s32 off)
{
enum ip_conntrack_info ctinfo;
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
@@ -592,6 +592,7 @@ static unsigned int nf_nat_sdp_media(struct sk_buff *skb, unsigned int protoff,
unsigned int medialen,
union nf_inet_addr *rtp_addr)
{
+ struct nf_conntrack_expect *rtp_pair[2] = { rtp_exp, rtcp_exp };
enum ip_conntrack_info ctinfo;
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
@@ -622,24 +623,15 @@ static unsigned int nf_nat_sdp_media(struct sk_buff *skb, unsigned int protoff,
int ret;
rtp_exp->tuple.dst.u.udp.port = htons(port);
- ret = nf_ct_expect_related(rtp_exp,
- NF_CT_EXP_F_SKIP_MASTER);
- if (ret == -EBUSY)
- continue;
- else if (ret < 0) {
- port = 0;
- break;
- }
rtcp_exp->tuple.dst.u.udp.port = htons(port + 1);
- ret = nf_ct_expect_related(rtcp_exp,
- NF_CT_EXP_F_SKIP_MASTER);
+
+ ret = nf_ct_expect_related_pair(rtp_pair,
+ NF_CT_EXP_F_SKIP_MASTER);
if (ret == 0)
break;
- else if (ret == -EBUSY) {
- nf_ct_unexpect_related(rtp_exp);
+ else if (ret == -EBUSY)
continue;
- } else if (ret < 0) {
- nf_ct_unexpect_related(rtp_exp);
+ else if (ret < 0) {
port = 0;
break;
}
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index a9eaf9455c7783..af357f6c5070b1 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -45,8 +45,6 @@ enum {
NFT_VALIDATE_DO,
};
-static struct rhltable nft_objname_ht;
-
static u32 nft_chain_hash(const void *data, u32 len, u32 seed);
static u32 nft_chain_hash_obj(const void *data, u32 len, u32 seed);
static int nft_chain_hash_cmp(struct rhashtable_compare_arg *, const void *);
@@ -1635,6 +1633,10 @@ static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,
if (err)
goto err_chain_ht;
+ err = rhltable_init(&table->objname_ht, &nft_objname_ht_params);
+ if (err < 0)
+ goto err_obj_ht;
+
INIT_LIST_HEAD(&table->chains);
INIT_LIST_HEAD(&table->sets);
INIT_LIST_HEAD(&table->objects);
@@ -1653,6 +1655,8 @@ static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,
list_add_tail_rcu(&table->list, &nft_net->tables);
return 0;
err_trans:
+ rhltable_destroy(&table->objname_ht);
+err_obj_ht:
rhltable_destroy(&table->chains_ht);
err_chain_ht:
kfree(table->udata);
@@ -1819,6 +1823,7 @@ static void nf_tables_table_destroy(struct nft_table *table)
return;
rhltable_destroy(&table->chains_ht);
+ rhltable_destroy(&table->objname_ht);
kfree(table->name);
kfree(table->udata);
kfree(table);
@@ -8086,7 +8091,7 @@ void nft_unregister_obj(struct nft_object_type *obj_type)
EXPORT_SYMBOL_GPL(nft_unregister_obj);
struct nft_object *nft_obj_lookup(const struct net *net,
- const struct nft_table *table,
+ struct nft_table *table,
const struct nlattr *nla, u32 objtype,
u8 genmask)
{
@@ -8102,7 +8107,7 @@ struct nft_object *nft_obj_lookup(const struct net *net,
!lockdep_commit_lock_is_held(net));
rcu_read_lock();
- list = rhltable_lookup(&nft_objname_ht, &k, nft_objname_ht_params);
+ list = rhltable_lookup(&table->objname_ht, &k, nft_objname_ht_params);
if (!list)
goto out;
@@ -8382,7 +8387,7 @@ static int nf_tables_newobj(struct sk_buff *skb, const struct nfnl_info *info,
if (err < 0)
goto err_trans;
- err = rhltable_insert(&nft_objname_ht, &obj->rhlhead,
+ err = rhltable_insert(&table->objname_ht, &obj->rhlhead,
nft_objname_ht_params);
if (err < 0)
goto err_obj_ht;
@@ -8567,8 +8572,8 @@ nf_tables_getobj_single(u32 portid, const struct nfnl_info *info,
struct netlink_ext_ack *extack = info->extack;
u8 genmask = nft_genmask_cur(info->net);
u8 family = info->nfmsg->nfgen_family;
- const struct nft_table *table;
struct net *net = info->net;
+ struct nft_table *table;
struct nft_object *obj;
struct sk_buff *skb2;
u32 objtype;
@@ -10437,9 +10442,9 @@ static void nf_tables_commit_chain(struct net *net, struct nft_chain *chain)
nf_tables_commit_chain_free_rules_old(g0);
}
-static void nft_obj_del(struct nft_object *obj)
+static void nft_obj_del(struct nft_table *table, struct nft_object *obj)
{
- rhltable_remove(&nft_objname_ht, &obj->rhlhead, nft_objname_ht_params);
+ rhltable_remove(&table->objname_ht, &obj->rhlhead, nft_objname_ht_params);
list_del_rcu(&obj->list);
}
@@ -11124,7 +11129,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
break;
case NFT_MSG_DELOBJ:
case NFT_MSG_DESTROYOBJ:
- nft_obj_del(nft_trans_obj(trans));
+ nft_obj_del(table, nft_trans_obj(trans));
nf_tables_obj_notify(&ctx, nft_trans_obj(trans),
trans->msg_type);
break;
@@ -11416,7 +11421,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
nft_trans_destroy(trans);
} else {
nft_use_dec_restore(&table->use);
- nft_obj_del(nft_trans_obj(trans));
+ nft_obj_del(table, nft_trans_obj(trans));
}
break;
case NFT_MSG_DELOBJ:
@@ -12043,7 +12048,7 @@ static void __nft_release_table(struct net *net, struct nft_table *table)
nft_set_destroy(&ctx, set);
}
list_for_each_entry_safe(obj, ne, &table->objects, list) {
- nft_obj_del(obj);
+ nft_obj_del(table, obj);
nft_use_dec(&table->use);
nft_obj_destroy(&ctx, obj);
}
@@ -12225,10 +12230,6 @@ static int __init nf_tables_module_init(void)
if (err < 0)
goto err_netdev_notifier;
- err = rhltable_init(&nft_objname_ht, &nft_objname_ht_params);
- if (err < 0)
- goto err_rht_objname;
-
err = nft_offload_init();
if (err < 0)
goto err_offload;
@@ -12251,8 +12252,6 @@ static int __init nf_tables_module_init(void)
err_netlink_notifier:
nft_offload_exit();
err_offload:
- rhltable_destroy(&nft_objname_ht);
-err_rht_objname:
unregister_netdevice_notifier(&nf_tables_flowtable_notifier);
err_netdev_notifier:
nf_tables_core_module_exit();
@@ -12274,7 +12273,6 @@ static void __exit nf_tables_module_exit(void)
unregister_pernet_subsys(&nf_tables_net_ops);
cancel_work_sync(&trans_gc_work);
rcu_barrier();
- rhltable_destroy(&nft_objname_ht);
nf_tables_core_module_exit();
}
diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index 391539a1ceaa77..8a4472fd77d9f2 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.c
@@ -259,9 +259,7 @@ static int nft_payload_dump(struct sk_buff *skb,
static bool nft_payload_offload_mask(struct nft_offload_reg *reg,
u32 priv_len, u32 field_len)
{
- unsigned int remainder, delta, k;
struct nft_data mask = {};
- __be32 remainder_mask;
if (priv_len == field_len) {
memset(®->mask, 0xff, priv_len);
@@ -270,15 +268,7 @@ static bool nft_payload_offload_mask(struct nft_offload_reg *reg,
return false;
}
- memset(&mask, 0xff, field_len);
- remainder = priv_len % sizeof(u32);
- if (remainder) {
- k = priv_len / sizeof(u32);
- delta = field_len - priv_len;
- remainder_mask = htonl(~((1 << (delta * BITS_PER_BYTE)) - 1));
- mask.data[k] = (__force u32)remainder_mask;
- }
-
+ memset(&mask, 0xff, priv_len);
memcpy(®->mask, &mask, field_len);
return true;
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 2704b4b60d1e04..9af0fa895f7302 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -117,6 +117,7 @@ struct xt_hashlimit_htable {
refcount_t use;
u_int8_t family;
bool rnd_initialized;
+ bool ratematch;
struct hashlimit_cfg3 cfg; /* config */
@@ -323,6 +324,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
kvfree(hinfo);
return -ENOMEM;
}
+ hinfo->ratematch = !!(cfg->mode & XT_HASHLIMIT_RATE_MATCH);
spin_lock_init(&hinfo->lock);
switch (revision) {
@@ -872,7 +874,10 @@ static int hashlimit_mt_check_common(const struct xt_mtchk_param *par,
}
/* Check for overflow. */
- if (revision >= 3 && cfg->mode & XT_HASHLIMIT_RATE_MATCH) {
+ if (cfg->mode & XT_HASHLIMIT_RATE_MATCH) {
+ if (revision < 3)
+ return -EINVAL;
+
if (cfg->avg == 0 || cfg->avg > U32_MAX) {
pr_info_ratelimited("invalid rate\n");
return -ERANGE;
@@ -905,6 +910,15 @@ static int hashlimit_mt_check_common(const struct xt_mtchk_param *par,
mutex_unlock(&hashlimit_mutex);
return ret;
}
+ } else {
+ if ((cfg->mode & XT_HASHLIMIT_RATE_MATCH &&
+ !(*hinfo)->ratematch) ||
+ (!(cfg->mode & XT_HASHLIMIT_RATE_MATCH) &&
+ (*hinfo)->ratematch)) {
+ mutex_unlock(&hashlimit_mutex);
+ htable_put(*hinfo);
+ return -EINVAL;
+ }
}
mutex_unlock(&hashlimit_mutex);
diff --git a/tools/testing/selftests/net/netfilter/nft_flowtable.sh b/tools/testing/selftests/net/netfilter/nft_flowtable.sh
index fb1c59d45567af..449c518bd947dc 100755
--- a/tools/testing/selftests/net/netfilter/nft_flowtable.sh
+++ b/tools/testing/selftests/net/netfilter/nft_flowtable.sh
@@ -617,7 +617,11 @@ ip -6 -net "$nsr2" route add default via fee1:3::1
ip -net "$ns2" route add default via 10.0.2.1
ip -6 -net "$ns2" route add default via dead:2::1
+ip netns exec "$nsr1" nft -a insert rule inet filter forward \
+ 'meta oif tun0 tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept'
ip netns exec "$nsr1" nft -a insert rule inet filter forward 'meta oif tun0 accept'
+ip netns exec "$nsr1" nft -a insert rule inet filter forward \
+ 'meta oif tun6 tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept'
ip netns exec "$nsr1" nft -a insert rule inet filter forward 'meta oif tun6 accept'
ip netns exec "$nsr1" nft -a insert rule inet filter forward \
'meta oif "veth0" tcp sport 12345 ct mark set 1 flow add @f1 counter name routed_repl accept'
@@ -629,7 +633,7 @@ if ! test_tcp_forwarding_nat "$ns1" "$ns2" 1 "IPIP tunnel"; then
fi
if test_tcp_forwarding "$ns1" "$ns2" 1 6 "[dead:2::99]" 12345; then
- echo "PASS: flow offload for ns1/ns2 IP6IP6 tunnel"
+ check_counters "flow offload for ns1/ns2 IP6IP6 tunnel"
else
echo "FAIL: flow offload for ns1/ns2 with IP6IP6 tunnel" 1>&2
ip netns exec "$nsr1" nft list ruleset
@@ -642,6 +646,8 @@ ip -net "$nsr1" link set veth1.10 up
ip -net "$nsr1" addr add 192.168.20.1/24 dev veth1.10
ip -net "$nsr1" addr add fee1:4::1/64 dev veth1.10 nodad
ip netns exec "$nsr1" sysctl net.ipv4.conf.veth1/10.forwarding=1 > /dev/null
+ip netns exec "$nsr1" nft -a insert rule inet filter forward \
+ 'meta oif veth1.10 tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept'
ip netns exec "$nsr1" nft -a insert rule inet filter forward 'meta oif veth1.10 accept'
ip -net "$nsr1" link add name tun0.10 type ipip local 192.168.20.1 remote 192.168.20.2
@@ -649,6 +655,8 @@ ip -net "$nsr1" link set tun0.10 up
ip -net "$nsr1" addr add 192.168.200.1/24 dev tun0.10
ip -net "$nsr1" route change default via 192.168.200.2
ip netns exec "$nsr1" sysctl net.ipv4.conf.tun0/10.forwarding=1 > /dev/null
+ip netns exec "$nsr1" nft -a insert rule inet filter forward \
+ 'meta oif tun0.10 tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept'
ip netns exec "$nsr1" nft -a insert rule inet filter forward 'meta oif tun0.10 accept'
ip -net "$nsr1" link add name tun6.10 type ip6tnl local fee1:4::1 remote fee1:4::2 encaplimit none
@@ -656,6 +664,8 @@ ip -net "$nsr1" link set tun6.10 up
ip -net "$nsr1" addr add fee1:5::1/64 dev tun6.10 nodad
ip -6 -net "$nsr1" route delete default
ip -6 -net "$nsr1" route add default via fee1:5::2
+ip netns exec "$nsr1" nft -a insert rule inet filter forward \
+ 'meta oif tun6.10 tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept'
ip netns exec "$nsr1" nft -a insert rule inet filter forward 'meta oif tun6.10 accept'
ip -net "$nsr2" link add link veth0 name veth0.10 type vlan id 10
@@ -683,7 +693,7 @@ if ! test_tcp_forwarding_nat "$ns1" "$ns2" 1 "IPIP tunnel over vlan"; then
fi
if test_tcp_forwarding "$ns1" "$ns2" 1 6 "[dead:2::99]" 12345; then
- echo "PASS: flow offload for ns1/ns2 IP6IP6 tunnel over vlan"
+ check_counters "flow offload for ns1/ns2 IP6IP6 tunnel over vlan"
else
echo "FAIL: flow offload for ns1/ns2 with IP6IP6 tunnel over vlan" 1>&2
ip netns exec "$nsr1" nft list ruleset
|
| 3/2 | 2026/07/23 23:37 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 29448 output: 34 thoughts: 627 Thoughts: **My Analysis of This Patch Series** Okay, so I've got a patch series here that touches several key network subsystems. My initial assessment is that these changes are highly functional and reach into some very crucial network filtering and load balancing logic, so, as an expert, I can tell immediately, yes, **WorthFuzzing=true**. Let's break down the areas and identify the critical aspects, the potential "FocusSymbols" and the relevant "EnableConfigs" we'll need to consider for testing. First, we're looking at **`net/netfilter/ipvs/`**. This is IPVS, the IP Virtual Server stuff, right in the core: connection handling, NAT, the works. I need to focus on these functions: `ip_vs_conn_fill_cport`, `ip_vs_conn_change_fwd_mask`, `ip_vs_nat_icmp`, `ip_vs_nat_icmp_v6`, `ip_vs_out_icmp`, `ip_vs_in_icmp`, `ip_vs_icmp_xmit`, `ip_vs_icmp_xmit_v6`. Make sure `IP_VS`, `IP_VS_IPV6`, `IP_VS_PROTO_TCP`, `IP_VS_PROTO_UDP`, and `IP_VS_PROTO_SCTP` are all enabled and functional for these. Next, we've got Conntrack expectation handling and the SIP/H.323 NAT helpers in **`net/netfilter/`**. Specifically, `nf_conntrack_expect.c`, `nf_conntrack_sip.c`, `nf_nat_sip.c`, and `nf_nat_h323.c`. I need to zero in on: `nf_ct_expect_related_pair`, `nat_rtp_rtcp`, `nf_nat_sdp_media`. Configs `NF_CONNTRACK`, `NF_CONNTRACK_SIP`, `NF_NAT_SIP`, `NF_CONNTRACK_H323`, and `NF_NAT_H323` are the key enabling flags here. Moving on, we're looking at **`net/netfilter/ipset/ip_set_hash_gen.h`** and **`net/netfilter/nf_tables_api.c`**. Looks like `nf_tables` is using `rhltable` for object lookup by name. For `nf_tables`, the functions that I need to investigate are: `nft_obj_lookup`, `nf_tables_newtable`, `nf_tables_table_destroy`, `nf_tables_newobj`, `nf_tables_commit`, and `__nf_tables_abort`. I'll need `NF_TABLES` to test this properly. Also, there are some fixes related to **`net/netfilter/nft_payload.c`** and **`net/netfilter/xt_hashlimit.c`**. Lastly, the **`xt_hashlimit.c`** fix looks like it's impacting `hashlimit_mt_check_common` and `htable_create`. This looks important, so make sure `NETFILTER_XT_MATCH_HASHLIMIT` is set. Now, let's verify these configs using code search; make sure everything's set up correctly. This gives us a solid basis for targeted testing. |
| 4/2 | 2026/07/23 23:38 | tool | grepper |
0mArgs:{
"Expression": "config IP_VS",
"PathPrefix": "net/netfilter/ipvs/Kconfig"
}Results: {
"Output": "net/netfilter/ipvs/Kconfig-4-#\nnet/netfilter/ipvs/Kconfig:5:menuconfig IP_VS\nnet/netfilter/ipvs/Kconfig-6-\ttristate \"IP virtual server support\"\n--\nnet/netfilter/ipvs/Kconfig=286=comment 'IPVS SH scheduler'\nnet/netfilter/ipvs/Kconfig-287-\nnet/netfilter/ipvs/Kconfig:288:config IP_VS_SH_TAB_BITS\nnet/netfilter/ipvs/Kconfig-289-\tint \"IPVS source hashing table size (the Nth power of 2)\"\n--\nnet/netfilter/ipvs/Kconfig=301=comment 'IPVS MH scheduler'\nnet/netfilter/ipvs/Kconfig-302-\nnet/netfilter/ipvs/Kconfig:303:config IP_VS_MH_TAB_INDEX\nnet/netfilter/ipvs/Kconfig-304-\tint \"IPVS maglev hashing table index of size (the prime numbers)\"\n"
} |
| 5/2 | 2026/07/23 23:38 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 31123 output: 37 thoughts: 12 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Analyzing the `IP_VS_IPV6` Configuration** Right, let's dive straight in. I need to get a handle on the current state of `IP_VS_IPV6`. Understanding its configuration is critical, of course, because it's the bedrock of how traffic is being handled in this environment. Specifically, my mind is currently focused on: * **Its status:** Is it enabled, disabled, or partially configured? What kernel module versions are we working with? * **Conflict resolution:** I'm mentally parsing if there are existing rules or configurations that may conflict with our desired configurations. This means a methodical examination of the current setup to see if it plays well with the rest of the infrastructure. * **Security implications:** What are the security policy considerations with the use of the IPV6 module? * **Optimization:** What optimizations, if any, have been applied previously? Is there any documentation on the current configuration? Essentially, I'm mentally going through my checklist to make sure I understand the fundamentals before I start digging into more complex scenarios. |
| 6/2 | 2026/07/23 23:38 | tool | grepper |
0mError:no matches Args: {
"Expression": "config IP_VS_IPV6",
"PathPrefix": "net/netfilter/ipvs/Kconfig"
}Results: {
"error": "no matches"
} |
| 7/2 | 2026/07/23 23:38 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 31432 output: 27 thoughts: 44 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Investigating the IPVS/IPv6 Configuration** Alright, a configuration dependency popped up, specifically `IP_VS_IPV6`, and the hint points to `net/netfilter/ipvs/Kconfig`. That sounds about right, though I always double-check these things. My initial thought is to either jump directly to `net/netfilter/Kconfig` and take a look around, or, to keep things quick, I'll just run a `grep` for the symbol. That should give me the broader context really fast - where else it's referenced, dependencies, and so on. Efficiency is key when navigating these config structures. |
| 8/2 | 2026/07/23 23:38 | tool | grepper |
0mError:no matches Args: {
"Expression": "config IP_VS_IPV6",
"PathPrefix": ""
}Results: {
"error": "no matches"
} |
| 9/2 | 2026/07/23 23:38 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 31672 output: 36 thoughts: 28 Thoughts: Okay, here's my summary, presented as a stream of thought: **Diving into the IPv6 Load Balancing Configuration** Right, so I'm seeing `CONFIG_IP_VS_IPV6` sprinkled throughout this code. Okay, let's trace this and see where this preprocessor macro is actually defined. I need to understand the conditions under which this IPv6 support is enabled, because that will significantly impact the behavior and functionality of the load balancing features I'm looking at. I'll need to check the relevant configuration files and Kconfig options. It's crucial I grasp the context of this macro to follow the logic and reasoning behind these implementation choices. |
| 10/2 | 2026/07/23 23:38 | tool | grepper |
0mArgs:{
"Expression": "IP_VS_IPV6",
"PathPrefix": "net/netfilter/ipvs/Kconfig"
}Results: {
"Output": "net/netfilter/ipvs/Kconfig=27=if IP_VS\nnet/netfilter/ipvs/Kconfig-28-\nnet/netfilter/ipvs/Kconfig:29:config\tIP_VS_IPV6\nnet/netfilter/ipvs/Kconfig-30-\tbool \"IPv6 support for IPVS\"\n"
} |
| 11/2 | 2026/07/23 23:38 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 31971 output: 26 thoughts: 53 Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience: **Debugging a Kernel Configuration Setting** Right, so I've been wrestling with this configuration option, and it's staring me in the face. It's actually `config IP_VS_IPV6`, but I completely missed the tab character when I was building my regular expression. I was running `config IP_VS_IPV6` instead! Rookie mistake, I really should have known better, I really should have tested it against the source a bit more vigorously. Now that I've hopefully cleared up that one potential red herring, I need to check out a couple other, related settings for the NAT subsystem. Let's see... I'll check `NF_NAT_SIP` and `NF_NAT_H323` to make sure there are no other configurations causing a conflict or unexpected interactions, particularly around those voice-over-IP or session establishment scenarios. It's time to dig into the actual code now! |
| 12/2 | 2026/07/23 23:38 | tool | grepper |
0mArgs:{
"Expression": "config NF_NAT_SIP",
"PathPrefix": ""
}Results: {
"Output": "net/netfilter/Kconfig=426=config NF_NAT_IRC\n--\nnet/netfilter/Kconfig-430-\nnet/netfilter/Kconfig:431:config NF_NAT_SIP\nnet/netfilter/Kconfig-432-\ttristate\n"
} |
| 13/2 | 2026/07/23 23:38 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 32346 output: 29 thoughts: 12 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person: **NF_NAT_H323 - A Lingering Question** Alright, so we're looking at network address translation, probably within the context of something like a firewall or a router, right? We're dealing with NAT, that's clear. But the immediate question that pops into my head is *specifically* `NF_NAT_H323`. What about it? It’s a very pointed query, so something’s piqued my interest regarding H.323. Perhaps there's a particular problem I'm trying to diagnose. Maybe I'm troubleshooting an H.323-based VoIP setup and I'm wondering if a specific module related to that protocol is being handled correctly. Or I'm considering the performance implications or even the security vulnerabilities associated with its NAT implementation. Is it properly managing the signaling and media streams? Are there any known issues with that connection tracking helper that I need to be aware of? Is it something I need to configure, debug, or maybe even replace? The lack of context implies that I've already set a lot of stage, and that just the name of a specific module related to H.323 is enough to spur thought. Ultimately, I'm trying to get to the root of a very specific, and probably non-trivial, detail within this whole network translation process. I need more information to continue my line of reasoning, but that single module name is clearly the key to unlocking the next piece of this puzzle. |
| 14/2 | 2026/07/23 23:38 | tool | grepper |
0mArgs:{
"Expression": "config NF_NAT_H323",
"PathPrefix": ""
}Results: {
"Output": "net/ipv4/netfilter/Kconfig=118=config NF_NAT_PPTP\n--\nnet/ipv4/netfilter/Kconfig-122-\nnet/ipv4/netfilter/Kconfig:123:config NF_NAT_H323\nnet/ipv4/netfilter/Kconfig-124-\ttristate\n"
} |
| 15/2 | 2026/07/23 23:38 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 32823 output: 31 thoughts: 14 Thoughts: Okay, here's my attempt at summarizing those thoughts from an expert's perspective, using a first-person perspective: **Thinking About Hashlimits and Netfilter** Hmm, `NETFILTER_XT_MATCH_HASHLIMIT`. That's the one that always makes me think... how robust is the implementation really? What are the key performance considerations at scale? Is it thread-safe in all the ways it *needs* to be? Are there any subtle race conditions lurking that might rear their ugly heads under heavy load, causing unexpected drops or even worse, security implications? I need to refresh my understanding of its internal data structures – how are collisions handled within the hash table? And what about memory consumption with a large number of rules? Are there any gotchas around the configuration of the hash limits themselves? I should review the documentation and recent patches... |
| 16/2 | 2026/07/23 23:38 | tool | grepper |
0mArgs:{
"Expression": "config NETFILTER_XT_MATCH_HASHLIMIT",
"PathPrefix": ""
}Results: {
"Output": "net/netfilter/Kconfig=1314=config NETFILTER_XT_MATCH_ESP\n--\nnet/netfilter/Kconfig-1322-\nnet/netfilter/Kconfig:1323:config NETFILTER_XT_MATCH_HASHLIMIT\nnet/netfilter/Kconfig-1324-\ttristate '\"hashlimit\" match support'\n"
} |
| 17/2 | 2026/07/23 23:38 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 33146 output: 27 thoughts: 33 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Examining Essential Network Protocol Constants** Alright, let's get down to brass tacks. I need to make sure I have the fundamental constants straight in my head, specifically related to the Virtual Server (VS) implementation. I'm going to quickly verify the correct definitions for the protocol identifiers. Specifically, I need to confirm the values and any potential nuances of `IP_VS_PROTO_TCP`, `IP_VS_PROTO_UDP`, and `IP_VS_PROTO_SCTP`. I want to make sure I don't miss a beat. After all, incorrect values here could lead to some significant and easily overlooked errors downstream in traffic routing or health checks. Let me make sure I know the values. I need to get this right. |
| 18/2 | 2026/07/23 23:38 | tool | grepper |
0mError:no matches Args: {
"Expression": "config IP_VS_PROTO_",
"PathPrefix": ""
}Results: {
"error": "no matches"
} |
| 19/2 | 2026/07/23 23:38 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 33396 output: 37 thoughts: 22 Thoughts: Here's my thought process, as requested: **Checking the IPVS Config for PROTO_TCP** Okay, so I need to find the configuration options related to TCP within the IP Virtual Server code. My instinct says the central configuration file would be the `Kconfig` file, located under the `net/netfilter/ipvs/` directory. That's usually where kernel modules define their build options. So, first things first, I'll need to check `net/netfilter/ipvs/Kconfig`. Specifically, I'm looking for anything related to `PROTO_TCP`. This should point me towards how TCP load balancing and other related TCP-specific features within IPVS are configured. That's the logical place to start digging. |
| 20/2 | 2026/07/23 23:38 | tool | grepper |
0mArgs:{
"Expression": "IP_VS_PROTO_TCP",
"PathPrefix": "net/netfilter/ipvs/Kconfig"
}Results: {
"Output": "net/netfilter/ipvs/Kconfig=77=comment \"IPVS transport protocol load balancing support\"\nnet/netfilter/ipvs/Kconfig-78-\nnet/netfilter/ipvs/Kconfig:79:config\tIP_VS_PROTO_TCP\nnet/netfilter/ipvs/Kconfig-80-\tbool \"TCP load balancing support\"\n--\nnet/netfilter/ipvs/Kconfig=321=config\tIP_VS_FTP\nnet/netfilter/ipvs/Kconfig-322-\ttristate \"FTP protocol helper\"\nnet/netfilter/ipvs/Kconfig:323:\tdepends on IP_VS_PROTO_TCP \u0026\u0026 NF_CONNTRACK \u0026\u0026 NF_NAT \u0026\u0026 \\\nnet/netfilter/ipvs/Kconfig-324-\t\tNF_CONNTRACK_FTP\n"
} |
| 21/2 | 2026/07/23 23:38 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 33822 output: 407 thoughts: 973 Thoughts: **Refining the Symbol Set for Analysis** Alright, let's get down to business. I've got a list of symbols I need to examine related to IPVS, conntrack, Netfilter tables, and hashlimit. First, I've confirmed that `IP_VS_PROTO_TCP`, `IP_VS_PROTO_UDP`, and `IP_VS_PROTO_SCTP` are all valid protocol definitions within this context. Now, let's clarify the configurations required. I've noted down the relevant configurations: `IP_VS`, `IP_VS_IPV6`, `IP_VS_PROTO_TCP`, `IP_VS_PROTO_UDP`, `IP_VS_PROTO_SCTP`, `NF_CONNTRACK_SIP`, `NF_NAT_SIP`, `NF_CONNTRACK_H323`, `NF_NAT_H323`, `NF_TABLES`, and `NETFILTER_XT_MATCH_HASHLIMIT`. Next, I'm diving into the more granular symbols, focusing on those that are likely relevant. For IPVS, I've identified: `ip_vs_conn_fill_cport`, `ip_vs_conn_change_fwd_mask`, `ip_vs_nat_icmp`, `ip_vs_nat_icmp_v6`, `ip_vs_out_icmp`, `ip_vs_in_icmp`, `ip_vs_icmp_xmit`, `ip_vs_icmp_xmit_v6`, `tcp_csum_check`, `udp_csum_check`, and `sctp_csum_check`. In the conntrack realm, I'm looking at: `nf_ct_expect_related_pair`, `nat_rtp_rtcp`, and `nf_nat_sdp_media`. Netfilter tables are represented by: `nft_obj_lookup`, `nf_tables_newtable`, `nf_tables_table_destroy`, `nf_tables_newobj`, and `nft_obj_del`. Finally, for xt_hashlimit, the functions of interest are: `hashlimit_mt_check_common` and `htable_create`. Now, a quick check on the visibility of functions is necessary. It seems `nft_obj_del` is static within `nf_tables_api.c`. Further, `nf_tables_newtable`, `nf_tables_table_destroy`, and `nf_tables_newobj` are also static. Although these are static functions, they're reachable through netlink. However, `nf_tables_table_destroy` is static, so I'll avoid including it. I'll stick with `nft_obj_lookup` and `nf_tables_newtable`, which are accessible. `nf_ct_expect_related_pair` is exported, so it's good. `nat_rtp_rtcp` and `nf_nat_sdp_media` are static, residing in `nf_nat_h323.c` and `nf_nat_sip.c` respectively. Checking the IPVS functions again, I find that `ip_vs_conn_change_fwd_mask` is static in `ip_vs_conn.c`. `ip_vs_conn_fill_cport`, `ip_vs_nat_icmp`, `ip_vs_nat_icmp_v6`, `ip_vs_icmp_xmit`, `ip_vs_icmp_xmit_v6` are exported. `ip_vs_out_icmp` and `ip_vs_in_icmp` are static in `ip_vs_core.c`. Based on this analysis, I've finalized my set of symbols to include: `ip_vs_conn_fill_cport`, `ip_vs_conn_change_fwd_mask`, `ip_vs_nat_icmp`, `ip_vs_nat_icmp_v6`, `ip_vs_out_icmp`, `ip_vs_in_icmp`, `ip_vs_icmp_xmit`, `ip_vs_icmp_xmit_v6`, `tcp_csum_check`, `udp_csum_check`, `sctp_csum_check`, `nf_ct_expect_related_pair`, `nat_rtp_rtcp`, `nf_nat_sdp_media`, `nft_obj_lookup`, `nf_tables_newtable`, `nf_tables_newobj`, `nft_obj_del`, and `hashlimit_mt_check_common`. I believe this is a comprehensive list and should provide the necessary |
| 22/2 | 2026/07/23 23:39 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"IP_VS",
"IP_VS_IPV6",
"IP_VS_PROTO_TCP",
"IP_VS_PROTO_UDP",
"IP_VS_PROTO_SCTP",
"NF_CONNTRACK_SIP",
"NF_NAT_SIP",
"NF_CONNTRACK_H323",
"NF_NAT_H323",
"NF_TABLES",
"NETFILTER_XT_MATCH_HASHLIMIT"
],
"FocusSymbols": [
"ip_vs_conn_fill_cport",
"ip_vs_conn_change_fwd_mask",
"ip_vs_nat_icmp",
"ip_vs_nat_icmp_v6",
"ip_vs_out_icmp",
"ip_vs_in_icmp",
"ip_vs_icmp_xmit",
"ip_vs_icmp_xmit_v6",
"tcp_csum_check",
"udp_csum_check",
"sctp_csum_check",
"nf_ct_expect_related_pair",
"nat_rtp_rtcp",
"nf_nat_sdp_media",
"nft_obj_lookup",
"nf_tables_newtable",
"nf_tables_newobj",
"nft_obj_del",
"hashlimit_mt_check_common"
],
"Reasoning": "The patch series makes functional changes to multiple core networking and netfilter subsystems, including IPVS connection handling and ICMP/checksum processing, conntrack expectation handling for SIP and H.323, nf_tables object lookup mechanisms, and xt_hashlimit matching. These changes modify reachable kernel logic and should be fuzzed.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"IP_VS",
"IP_VS_IPV6",
"IP_VS_PROTO_TCP",
"IP_VS_PROTO_UDP",
"IP_VS_PROTO_SCTP",
"NF_CONNTRACK_SIP",
"NF_NAT_SIP",
"NF_CONNTRACK_H323",
"NF_NAT_H323",
"NF_TABLES",
"NETFILTER_XT_MATCH_HASHLIMIT"
],
"FocusSymbols": [
"ip_vs_conn_fill_cport",
"ip_vs_conn_change_fwd_mask",
"ip_vs_nat_icmp",
"ip_vs_nat_icmp_v6",
"ip_vs_out_icmp",
"ip_vs_in_icmp",
"ip_vs_icmp_xmit",
"ip_vs_icmp_xmit_v6",
"tcp_csum_check",
"udp_csum_check",
"sctp_csum_check",
"nf_ct_expect_related_pair",
"nat_rtp_rtcp",
"nf_nat_sdp_media",
"nft_obj_lookup",
"nf_tables_newtable",
"nf_tables_newobj",
"nft_obj_del",
"hashlimit_mt_check_common"
],
"Reasoning": "The patch series makes functional changes to multiple core networking and netfilter subsystems, including IPVS connection handling and ICMP/checksum processing, conntrack expectation handling for SIP and H.323, nf_tables object lookup mechanisms, and xt_hashlimit matching. These changes modify reachable kernel logic and should be fuzzed.",
"WorthFuzzing": true
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|