[ovs-dev,ovn-ipv6,21/26] ovn-util: Add solicited node addresses to ipv6_netaddr.
diff mbox

Message ID 1468306616-125783-22-git-send-email-jpettit@ovn.org
State Changes Requested
Headers show

Commit Message

Justin Pettit July 12, 2016, 6:56 a.m. UTC
Every IPv6 host has a link-local solicited node multicast address for
neighbor discovery.  This commit defines the solicited node address for
each IPv6 address added to a logical switch or router port.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
---
 ovn/lib/ovn-util.c | 4 ++++
 ovn/lib/ovn-util.h | 2 ++
 2 files changed, 6 insertions(+)

Comments

Ben Pfaff July 13, 2016, 8:05 p.m. UTC | #1
On Mon, Jul 11, 2016 at 11:56:51PM -0700, Justin Pettit wrote:
> Every IPv6 host has a link-local solicited node multicast address for
> neighbor discovery.  This commit defines the solicited node address for
> each IPv6 address added to a logical switch or router port.
> 
> Signed-off-by: Justin Pettit <jpettit@ovn.org>

Acked-by: Ben Pfaff <blp@ovn.org>

Patch
diff mbox

diff --git a/ovn/lib/ovn-util.c b/ovn/lib/ovn-util.c
index 3e0c138..7ad69ad 100644
--- a/ovn/lib/ovn-util.c
+++ b/ovn/lib/ovn-util.c
@@ -53,9 +53,12 @@  add_ipv6_netaddr(struct lport_addresses *laddrs, struct in6_addr addr,
     na->mask = ipv6_create_mask(plen);
     na->network = ipv6_addr_bitand(&addr, &na->mask);
     na->plen = plen;
+    in6_addr_solicited_node(&na->sn_addr, &addr);
 
     na->addr_s = xmalloc(INET6_ADDRSTRLEN);
     inet_ntop(AF_INET6, &addr, na->addr_s, INET6_ADDRSTRLEN);
+    na->sn_addr_s = xmalloc(INET6_ADDRSTRLEN);
+    inet_ntop(AF_INET6, &na->sn_addr, na->sn_addr_s, INET6_ADDRSTRLEN);
     na->network_s = xmalloc(INET6_ADDRSTRLEN);
     inet_ntop(AF_INET6, &na->network, na->network_s, INET6_ADDRSTRLEN);
 }
@@ -189,6 +192,7 @@  destroy_lport_addresses(struct lport_addresses *laddrs)
 
     for (int i = 0; i < laddrs->n_ipv6_addrs; i++) {
         free(laddrs->ipv6_addrs[i].addr_s);
+        free(laddrs->ipv6_addrs[i].sn_addr_s);
         free(laddrs->ipv6_addrs[i].network_s);
     }
     free(laddrs->ipv6_addrs);
diff --git a/ovn/lib/ovn-util.h b/ovn/lib/ovn-util.h
index b550ece..e9f3ec2 100644
--- a/ovn/lib/ovn-util.h
+++ b/ovn/lib/ovn-util.h
@@ -34,10 +34,12 @@  struct ipv4_netaddr {
 struct ipv6_netaddr {
     struct in6_addr addr;     /* fc00::1 */
     struct in6_addr mask;     /* ffff:ffff:ffff:ffff:: */
+    struct in6_addr sn_addr;  /* ff02:1:ff00::1 */
     struct in6_addr network;  /* fc00:: */
     unsigned int plen;        /* CIDR Prefix: 64 */
 
     char *addr_s;             /* "fc00::1" */
+    char *sn_addr_s;          /* "ff02:1:ff00::1" */
     char *network_s;          /* "fc00::" */
 };