From: Jianbo Liu <jianbol@nvidia.com>
To: <netdev@vger.kernel.org>, <davem@davemloft.net>,
<kuba@kernel.org>, <steffen.klassert@secunet.com>
Cc: Jianbo Liu <jianbol@nvidia.com>, Cosmin Ratiu <cratiu@nvidia.com>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
David Ahern <dsahern@kernel.org>,
"Eric Dumazet" <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>
Subject: [PATCH net-next 1/3] xfrm: Remove redundant state inner mode check
Date: Fri, 24 Oct 2025 05:31:35 +0300 [thread overview]
Message-ID: <20251024023931.65002-2-jianbol@nvidia.com> (raw)
In-Reply-To: <20251024023931.65002-1-jianbol@nvidia.com>
This check is redundant because xfrm_ip2inner_mode no longer returns
NULL, because of the change in commit c9500d7b7de8 ("xfrm: store
xfrm_mode directly, not its address").
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
---
net/ipv4/ip_vti.c | 8 +-------
net/ipv6/ip6_vti.c | 8 +-------
net/xfrm/xfrm_interface_core.c | 8 +-------
net/xfrm/xfrm_policy.c | 9 ++-------
4 files changed, 5 insertions(+), 28 deletions(-)
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 95b6bb78fcd2..91e889965918 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -120,14 +120,8 @@ static int vti_rcv_cb(struct sk_buff *skb, int err)
inner_mode = &x->inner_mode;
- if (x->sel.family == AF_UNSPEC) {
+ if (x->sel.family == AF_UNSPEC)
inner_mode = xfrm_ip2inner_mode(x, XFRM_MODE_SKB_CB(skb)->protocol);
- if (inner_mode == NULL) {
- XFRM_INC_STATS(dev_net(skb->dev),
- LINUX_MIB_XFRMINSTATEMODEERROR);
- return -EINVAL;
- }
- }
family = inner_mode->family;
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index ad5290be4dd6..67030918279c 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -364,14 +364,8 @@ static int vti6_rcv_cb(struct sk_buff *skb, int err)
inner_mode = &x->inner_mode;
- if (x->sel.family == AF_UNSPEC) {
+ if (x->sel.family == AF_UNSPEC)
inner_mode = xfrm_ip2inner_mode(x, XFRM_MODE_SKB_CB(skb)->protocol);
- if (inner_mode == NULL) {
- XFRM_INC_STATS(dev_net(skb->dev),
- LINUX_MIB_XFRMINSTATEMODEERROR);
- return -EINVAL;
- }
- }
family = inner_mode->family;
diff --git a/net/xfrm/xfrm_interface_core.c b/net/xfrm/xfrm_interface_core.c
index 330a05286a56..7084c7e6cf7a 100644
--- a/net/xfrm/xfrm_interface_core.c
+++ b/net/xfrm/xfrm_interface_core.c
@@ -389,14 +389,8 @@ static int xfrmi_rcv_cb(struct sk_buff *skb, int err)
if (xnet) {
inner_mode = &x->inner_mode;
- if (x->sel.family == AF_UNSPEC) {
+ if (x->sel.family == AF_UNSPEC)
inner_mode = xfrm_ip2inner_mode(x, XFRM_MODE_SKB_CB(skb)->protocol);
- if (inner_mode == NULL) {
- XFRM_INC_STATS(dev_net(skb->dev),
- LINUX_MIB_XFRMINSTATEMODEERROR);
- return -EINVAL;
- }
- }
if (!xfrm_policy_check(NULL, XFRM_POLICY_IN, skb,
inner_mode->family))
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 62486f866975..a1d995db6293 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2711,15 +2711,10 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
*/
xfrm_dst_set_child(xdst_prev, &xdst->u.dst);
- if (xfrm[i]->sel.family == AF_UNSPEC) {
+ if (xfrm[i]->sel.family == AF_UNSPEC)
inner_mode = xfrm_ip2inner_mode(xfrm[i],
xfrm_af2proto(family));
- if (!inner_mode) {
- err = -EAFNOSUPPORT;
- dst_release(dst);
- goto put_states;
- }
- } else
+ else
inner_mode = &xfrm[i]->inner_mode;
xdst->route = dst;
--
2.49.0
next prev parent reply other threads:[~2025-10-24 2:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-24 2:31 [PATCH net-next 0/3] xfrm: Correct inner packet family determination Jianbo Liu
2025-10-24 2:31 ` Jianbo Liu [this message]
2025-10-24 2:31 ` [PATCH net-next 2/3] xfrm: Check inner packet family directly from skb_dst Jianbo Liu
2025-10-24 11:26 ` Sabrina Dubroca
2025-10-27 1:50 ` Jianbo Liu
2025-10-24 2:31 ` [PATCH net-next 3/3] xfrm: Determine inner GSO type from packet inner protocol Jianbo Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251024023931.65002-2-jianbol@nvidia.com \
--to=jianbol@nvidia.com \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).