From: Cong Wang <amwang@redhat.com>
To: David Stevens <dlstevens@us.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, netdev-owner@vger.kernel.org,
Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [Patch net-next v3 3/4] vxlan: add ipv6 support
Date: Tue, 09 Apr 2013 14:58:15 +0800 [thread overview]
Message-ID: <1365490695.2557.12.camel@cr0> (raw)
In-Reply-To: <OF82703BAC.20223779-ON85257B47.0040E058-85257B47.0046C8A6@us.ibm.com>
On Mon, 2013-04-08 at 08:53 -0400, David Stevens wrote:
> And also, these change all occurrences in the file, which is
> why I suggested they be unique field names. This makes a common
> "struct sockaddr_in sin;" declaration a syntax error. I suggested
> naming them "vip_sin" (or better,as above, "va_sin", with the new
> vxlan_addr
> name) to make them unique field names, for the same reason it would
> be a bad idea to use "#define i u.sin"; because it is likely to
> create a problem maintaining it.
I will rename it to "va_sin".
>
> > port_max;
> > @@ -130,6 +146,59 @@ struct vxlan_dev {
> > #define VXLAN_F_L2MISS 0x08
> > #define VXLAN_F_L3MISS 0x10
> >
> > +static inline
> > +bool vxlan_addr_equal(const struct vxlan_addr *a, const struct
> vxlan_addr *b)
> > +{
> > +#if IS_ENABLED(CONFIG_IPV6)
> > + if (a->family != b->family)
> > + return false;
> > + if (a->family == AF_INET6)
> > + return ipv6_addr_equal(&a->sin6, &b->sin6);
> > + else
> > +#endif
> > + return a->sin == b->sin;
> > +}
>
> Still think something like
> #define vxlan_addr_equal(a, b) (memcmp((a),(b),sizeof(*a) == 0)
>
> is better.
Even for IPv4 where we just need to compare 4 bytes?
Also, if you want to use memcmp, you have to zero all the struct
vxlan_addr on stack.
> With your current definitions, "sin6" is just an in6_addr, but
> you are not checking the sin6_scope_id, which is not correct for IPv6
> link-local addresses. You can rely on "ifindex" in vxlan_rdst for
> fdb entries, but you'd at least need to make sure it is not 0 for LL
> scope, and you still need sin6_scope_id to match for calls in
> vxlan_snoop()
> and vxlan_group_used(). The same sin6_addr with different sin6_scope_id
> for link-local addrs is not the same address in v6.
> This is another reason to use memcmp(), and the whole
> sockaddr_in6,
> not just the sin6_addr part. You need code to require non-zero
> sin6_scope_id for
> link-local addrs in the netlink part regardless of how you fix the
> comparison here.
Alright, I will check sin6_scope_id as well.
> > +static int vxlan_nla_get_addr(struct vxlan_addr *ip, struct nlattr
> *nla)
> > +{
> > + if (nla_len(nla) == sizeof(struct in6_addr)) {
> > +#if IS_ENABLED(CONFIG_IPV6)
> > + nla_memcpy(&ip->sin6, nla, sizeof(struct in6_addr));
> > + ip->family = AF_INET6;
> > + return 0;
> > +#else
> > + return -EAFNOSUPPORT;
> > +#endif
> > + } else if (nla_len(nla) == sizeof(__be32)) {
> > + ip->sin = nla_get_be32(nla);
> > + ip->family = AF_INET;
> > + return 0;
> > + } else {
> > + return -EAFNOSUPPORT;
> > + }
> > +}
>
> You said in your other mail you already had a comment about
> padding here, but it isn't accounting for it. nla_ok() only requires
> nla_len() be >= sizeof(__be32) here.
>
Maybe I should change the '==' above to '>='?
next prev parent reply other threads:[~2013-04-09 6:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-08 2:18 [Patch net-next v3 1/4] vxlan: defer vxlan init as late as possible Cong Wang
2013-04-08 2:18 ` [Patch net-next v3 2/4] ipv6: export ipv6_sock_mc_join and ipv6_sock_mc_drop Cong Wang
2013-04-08 2:18 ` [Patch net-next v3 3/4] vxlan: add ipv6 support Cong Wang
2013-04-08 12:53 ` David Stevens
2013-04-09 6:58 ` Cong Wang [this message]
2013-04-09 10:47 ` Cong Wang
2013-04-15 13:27 ` David Stevens
2013-04-17 1:43 ` Cong Wang
2013-04-08 2:18 ` [Patch net-next v3 4/4] ipv6: Add generic UDP Tunnel segmentation Cong Wang
2013-04-08 2:18 ` [PATCH iproute2] vxlan: add ipv6 support Cong Wang
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=1365490695.2557.12.camel@cr0 \
--to=amwang@redhat.com \
--cc=davem@davemloft.net \
--cc=dlstevens@us.ibm.com \
--cc=netdev-owner@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.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 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.