]> git.proxmox.com Git - ovs.git/commitdiff
ovn: Add support for link-local addresses.
authorJustin Pettit <jpettit@ovn.org>
Sun, 26 Jun 2016 05:22:52 +0000 (22:22 -0700)
committerJustin Pettit <jpettit@ovn.org>
Fri, 29 Jul 2016 09:46:05 +0000 (02:46 -0700)
Every IPv6-enabled interface is supposed to have a link-local address
available to it.  This commit adds a link local interface to each router
port and scopes link-local routes to the ingress port that received the
packet.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
ovn/lib/ovn-util.c
ovn/northd/ovn-northd.8.xml
ovn/northd/ovn-northd.c
ovn/ovn-nb.xml

index 49bb05dd3b8d4526d409fc38be31346a49a3583e..b51cb4aefb52e7296145f071a1d8bc342bb5a010 100644 (file)
@@ -122,9 +122,11 @@ extract_lsp_addresses(char *address, struct lport_addresses *laddrs)
 /* Extracts the mac, IPv4 and IPv6 addresses from the
  * "nbrec_logical_router_port" parameter 'lrp'.  Stores the IPv4 and
  * IPv6 addresses in the 'ipv4_addrs' and 'ipv6_addrs' fields of
- * 'laddrs', respectively.
+ * 'laddrs', respectively.  In addition, a link local IPv6 address
+ * based on the 'mac' member of 'lrp' is added to the 'ipv6_addrs'
+ * field.
  *
- * Return true if at least 'MAC' is found in 'lrp', false otherwise.
+ * Return true if a valid 'mac' address is found in 'lrp', false otherwise.
  *
  * The caller must call destroy_lport_addresses(). */
 bool
@@ -175,6 +177,11 @@ extract_lrp_networks(const struct nbrec_logical_router_port *lrp,
         }
     }
 
+    /* Always add the IPv6 link local address. */
+    struct in6_addr lla;
+    in6_generate_lla(laddrs->ea, &lla);
+    add_ipv6_netaddr(laddrs, lla, 64);
+
     return true;
 }
 
index 93adbca4db5e7a8bb8e4c65b58ea0047c8a4a479..168c38dc3a02cb26dd2282946932006614c65384 100644 (file)
@@ -1131,6 +1131,11 @@ next;
           Instead, if the route is from a configured static route, <var>G</var>
           is the next hop IP address.  Else it is <code>ip6.dst</code>.
         </p>
+
+        <p>
+          If the address <var>A</var> is in the link-local scope, the
+          route will be limited to sending on the ingress port.
+        </p>
       </li>
     </ul>
 
index 4e0e072b352d40ca15b5b79685cf94416132152f..14ce1bad745f8f3ec18eda1b1c3724dd79fddc0f 100644 (file)
@@ -2777,9 +2777,18 @@ add_route(struct hmap *lflows, const struct ovn_port *op,
           const char *gateway)
 {
     bool is_ipv4 = strchr(network_s, '.') ? true : false;
+    struct ds match = DS_EMPTY_INITIALIZER;
 
-    char *match = xasprintf("ip%s.dst == %s/%d", is_ipv4 ? "4" : "6",
-                            network_s, plen);
+    /* IPv6 link-local addresses must be scoped to the local router port. */
+    if (!is_ipv4) {
+        struct in6_addr network;
+        ovs_assert(ipv6_parse(network_s, &network));
+        if (in6_is_lla(&network)) {
+            ds_put_format(&match, "inport == %s && ", op->json_key);
+        }
+    }
+    ds_put_format(&match, "ip%s.dst == %s/%d", is_ipv4 ? "4" : "6",
+                  network_s, plen);
 
     struct ds actions = DS_EMPTY_INITIALIZER;
     ds_put_format(&actions, "ip.ttl--; %sreg0 = ", is_ipv4 ? "" : "xx");
@@ -2802,10 +2811,10 @@ add_route(struct hmap *lflows, const struct ovn_port *op,
 
     /* The priority here is calculated to implement longest-prefix-match
      * routing. */
-    ovn_lflow_add(lflows, op->od, S_ROUTER_IN_IP_ROUTING, plen, match,
-                  ds_cstr(&actions));
+    ovn_lflow_add(lflows, op->od, S_ROUTER_IN_IP_ROUTING, plen,
+                  ds_cstr(&match), ds_cstr(&actions));
+    ds_destroy(&match);
     ds_destroy(&actions);
-    free(match);
 }
 
 static void
index 85aa2d3c63283623a3cd85080294f85e6d48dab2..4ce295a2935f6d5d113bb1b749e827bc419ad0a5 100644 (file)
         address is 192.168.0.1 and that packets destined to
         192.168.0.<var>x</var> should be routed to this port.
       </p>
+
+      <p>
+        A logical router port always adds a link-local IPv6 address
+        (fe80::/64) automatically generated from the interface's MAC
+        address using the modified EUI-64 format.
+      </p>
     </column>
 
     <column name="mac">