archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <>
To: "David S. Miller" <>,
	Alexey Kuznetsov <>,
	James Morris <>,
	Hideaki YOSHIFUJI <>,
	Patrick McHardy <>
Subject: [net-ipv4] question about arguments position
Date: Thu, 04 May 2017 11:07:54 -0500	[thread overview]
Message-ID: <> (raw)

Hello everybody,

While looking into Coverity ID 1357474 I ran into the following piece  
of code at net/ipv4/inet_diag.c:392:

struct sock *inet_diag_find_one_icsk(struct net *net,
                                      struct inet_hashinfo *hashinfo,
                                      const struct inet_diag_req_v2 *req)
         struct sock *sk;

         if (req->sdiag_family == AF_INET)
                 sk = inet_lookup(net, hashinfo, NULL, 0, req->id.idiag_dst[0],
                                  req->id.idiag_dport, req->id.idiag_src[0],
                                  req->id.idiag_sport, req->id.idiag_if);
         else if (req->sdiag_family == AF_INET6) {
                 if (ipv6_addr_v4mapped((struct in6_addr  
*)req->id.idiag_dst) &&
                     ipv6_addr_v4mapped((struct in6_addr *)req->id.idiag_src))
                         sk = inet_lookup(net, hashinfo, NULL, 0,  
                         sk = inet6_lookup(net, hashinfo, NULL, 0,
                                           (struct in6_addr  
                                           (struct in6_addr  

The issue here is that the position of arguments in the call to  
inet_lookup() and inet6_lookup() functions do not match the order of  
the parameters:

req->id.idiag_dport is passed to sport
req->id.idiag_sport is passed to dport

These are the function prototypes:

static inline struct sock *inet_lookup(struct net *net,
				       struct inet_hashinfo *hashinfo,
				       struct sk_buff *skb, int doff,
				       const __be32 saddr, const __be16 sport,
				       const __be32 daddr, const __be16 dport,
				       const int dif)

struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo,
			  struct sk_buff *skb, int doff,
			  const struct in6_addr *saddr, const __be16 sport,
			  const struct in6_addr *daddr, const __be16 dport,
			  const int dif)

My question here is if this is intentional?

In case it is not, I will send a patch to fix it. But first it would  
be great to hear any comment about it.

Thank you!
Gustavo A. R. Silva

             reply	other threads:[~2017-05-04 16:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 16:07 Gustavo A. R. Silva [this message]
2017-05-04 16:46 ` [net-ipv4] question about arguments position David Miller
2017-05-04 16:56   ` Gustavo A. R. Silva
2017-05-04 17:47   ` Joe Perches
2017-05-04 19:00     ` Gustavo A. R. Silva
2017-05-04 19:02       ` Joe Perches
2017-05-04 19:15         ` Gustavo A. R. Silva
2017-05-04 19:17           ` Joe Perches
2017-05-04 19:24             ` Gustavo A. R. Silva
2017-05-04 19:44               ` [PATCH] net: ipv4: add code comment for clarification Gustavo A. R. Silva
2017-05-08 15:36                 ` David Miller
2017-05-08 15:44                   ` Gustavo A. R. Silva

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \

* 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).