netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Samuelsson <ulf.samuelsson@ericsson.com>
To: <netdev@vger.kernel.org>
Subject: Possible bug in net/core/neighbor.c
Date: Wed, 5 Nov 2014 11:46:02 +0100	[thread overview]
Message-ID: <5459FFEA.3000101@ericsson.com> (raw)

I find the following in "net/core/neighbor.c"

     /* Compare new lladdr with cached one */
     if (!dev->addr_len) {
         /* First case: device needs no address. */
         lladdr = neigh->ha;
     } else if (lladdr) {
         /* The second case: if something is already cached
            and a new address is proposed:
            - compare new & old
            - if they are different, check override flag
          */

         /* POSSIBLE BUG */
         if ((old & NUD_VALID) &&
             !memcmp(lladdr, neigh->ha, dev->addr_len))
             lladdr = neigh->ha;
         /* END POSSIBLE BUG */
     } else {
         /* No address is supplied; if we know something,
            use it, otherwise discard the request.
          */
         err = -EINVAL;
         if (!(old & NUD_VALID))
             goto out;
         lladdr = neigh->ha;
     }

     It looks to me like the code is saying
         if the proposed address is equal to the original address,
             set the proposed address  to the original address.

     which is pretty meaningless.

     Should it not be:

         if ((old & NUD_VALID) &&
             memcmp(lladdr, neigh->ha, dev->addr_len))    /* True if 
addresses are not equal */
             neigh->ha = lladdr;             /* Update to new address */

     If not, I would appreciate an explanation what the code is doing.

-- 
Best Regards,
Ulf Samuelsson

             reply	other threads:[~2014-11-05 10:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-05 10:46 Ulf Samuelsson [this message]
2014-11-05 15:46 ` Possible bug in net/core/neighbor.c Ulf Samuelsson

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=5459FFEA.3000101@ericsson.com \
    --to=ulf.samuelsson@ericsson.com \
    --cc=netdev@vger.kernel.org \
    /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).