All of lore.kernel.org
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: kuniyu@amazon.com, "David S. Miller" <davem@davemloft.net>,
	 David Ahern <dsahern@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,  Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Breno Leitao <leitao@debian.org>,
	kernel-team@meta.com
Subject: [PATCH net-next 8/8] vxlan: Use nlmsg_payload in vxlan_vnifilter_dump
Date: Tue, 15 Apr 2025 12:28:59 -0700	[thread overview]
Message-ID: <20250415-nlmsg_v2-v1-8-a1c75d493fd7@debian.org> (raw)
In-Reply-To: <20250415-nlmsg_v2-v1-0-a1c75d493fd7@debian.org>

Leverage the new nlmsg_payload() helper to avoid checking for message
size and then reading the nlmsg data.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/vxlan/vxlan_vnifilter.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_vnifilter.c
index 6e6e9f05509ab..d0753776d3394 100644
--- a/drivers/net/vxlan/vxlan_vnifilter.c
+++ b/drivers/net/vxlan/vxlan_vnifilter.c
@@ -411,13 +411,12 @@ static int vxlan_vnifilter_dump(struct sk_buff *skb, struct netlink_callback *cb
 	struct tunnel_msg *tmsg;
 	struct net_device *dev;
 
-	if (cb->nlh->nlmsg_len < nlmsg_msg_size(sizeof(struct tunnel_msg))) {
+	tmsg = nlmsg_payload(cb->nlh, sizeof(*tmsg));
+	if (!tmsg) {
 		NL_SET_ERR_MSG(cb->extack, "Invalid msg length");
 		return -EINVAL;
 	}
 
-	tmsg = nlmsg_data(cb->nlh);
-
 	if (tmsg->flags & ~TUNNEL_MSG_VALID_USER_FLAGS) {
 		NL_SET_ERR_MSG(cb->extack, "Invalid tunnelmsg flags in ancillary header");
 		return -EINVAL;

-- 
2.47.1


  parent reply	other threads:[~2025-04-15 19:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15 19:28 [PATCH net-next 0/8] Adopting nlmsg_payload() in IPv4/IPv6 Breno Leitao
2025-04-15 19:28 ` [PATCH net-next 1/8] ipv6: Use nlmsg_payload in addrlabel file Breno Leitao
2025-04-16  0:54   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 2/8] ipv6: Use nlmsg_payload in addrconf file Breno Leitao
2025-04-16  0:56   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 3/8] ipv6: Use nlmsg_payload in route file Breno Leitao
2025-04-16  0:59   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 4/8] ipv4: Use nlmsg_payload in devinet file Breno Leitao
2025-04-16  1:00   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 5/8] ipv4: Use nlmsg_payload in fib_frontend file Breno Leitao
2025-04-16  1:03   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 6/8] ipv4: Use nlmsg_payload in route file Breno Leitao
2025-04-16  1:04   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 7/8] ipv4: Use nlmsg_payload in ipmr file Breno Leitao
2025-04-16  1:06   ` Kuniyuki Iwashima
2025-04-15 19:28 ` Breno Leitao [this message]
2025-04-16  1:13   ` [PATCH net-next 8/8] vxlan: Use nlmsg_payload in vxlan_vnifilter_dump Kuniyuki Iwashima
2025-04-16 13:55     ` Breno Leitao
2025-04-17  1:40 ` [PATCH net-next 0/8] Adopting nlmsg_payload() in IPv4/IPv6 patchwork-bot+netdevbpf

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=20250415-nlmsg_v2-v1-8-a1c75d493fd7@debian.org \
    --to=leitao@debian.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.