ovn: Remove 'default_gw' from logical router table.
authorJustin Pettit <jpettit@ovn.org>
Tue, 17 May 2016 13:02:53 +0000 (06:02 -0700)
committerJustin Pettit <jpettit@ovn.org>
Wed, 13 Jul 2016 04:14:03 +0000 (21:14 -0700)
With static routes, it's not necessary to have a separate default
gateway parameter.  This also makes configuring router ports clearer
when IPv6 and IPv4 addresses may be assigned to the same port.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
ovn/northd/ovn-northd.c
ovn/ovn-nb.ovsschema
ovn/ovn-nb.xml
tests/ovn.at

index d0491ea..ed67dc5 100644 (file)
@@ -262,10 +262,6 @@ struct ovn_datapath {
 
     struct ovs_list list;       /* In list of similar records. */
 
-    /* Logical router data (digested from nbr). */
-    const struct ovn_port *gateway_port;
-    ovs_be32 gateway;
-
     /* Logical switch data. */
     struct ovn_port **router_ports;
     size_t n_router_ports;
@@ -420,21 +416,6 @@ join_datapaths(struct northd_context *ctx, struct hmap *datapaths,
                                      NULL, nbr, NULL);
             ovs_list_push_back(nb_only, &od->list);
         }
-
-        od->gateway = 0;
-        if (nbr->default_gw) {
-            ovs_be32 ip;
-            if (!ip_parse(nbr->default_gw, &ip) || !ip) {
-                static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
-                VLOG_WARN_RL(&rl, "bad 'gateway' %s", nbr->default_gw);
-            } else {
-                od->gateway = ip;
-            }
-        }
-
-        /* Set the gateway port to NULL.  If there is a gateway, it will get
-         * filled in as we go through the ports later. */
-        od->gateway_port = NULL;
     }
 }
 
@@ -658,18 +639,6 @@ join_logical_ports(struct northd_context *ctx,
                 op->mac = mac;
 
                 op->od = od;
-
-                /* If 'od' has a gateway and 'op' routes to it... */
-                if (od->gateway && !((op->network ^ od->gateway) & op->mask)) {
-                    /* ...and if 'op' is a longer match than the current
-                     * choice... */
-                    const struct ovn_port *gw = od->gateway_port;
-                    int len = gw ? ip_count_cidr_bits(gw->mask) : 0;
-                    if (ip_count_cidr_bits(op->mask) > len) {
-                        /* ...then it's the default gateway port. */
-                        od->gateway_port = op;
-                    }
-                }
             }
         }
     }
@@ -2524,10 +2493,6 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
             route = od->nbr->static_routes[i];
             build_static_route_flow(lflows, od, ports, route);
         }
-
-        if (od->gateway && od->gateway_port) {
-            add_route(lflows, od->gateway_port, 0, 0, od->gateway);
-        }
     }
     /* XXX destination unreachable */
 
index ee7c2c6..5102948 100644 (file)
@@ -1,7 +1,7 @@
 {
     "name": "OVN_Northbound",
-    "version": "3.2.0",
-    "cksum": "1784604034 7539",
+    "version": "4.0.0",
+    "cksum": "2156178478 7460",
     "tables": {
         "Logical_Switch": {
             "columns": {
                                             "refType": "strong"},
                                    "min": 0,
                                    "max": "unlimited"}},
-                "default_gw": {"type": {"key": "string", "min": 0, "max": 1}},
                 "enabled": {"type": {"key": "boolean", "min": 0, "max": 1}},
                 "nat": {"type": {"key": {"type": "uuid",
                                          "refTable": "NAT",
index 5542ea4..1eeec22 100644 (file)
       One or more static routes for the router.
     </column>
 
-    <column name="default_gw">
-      IP address to use as default gateway, if any.
-    </column>
-
     <column name="enabled">
       This column is used to administratively set router state.  If this column
       is empty or is set to <code>true</code>, the router is enabled.  If this
index 63d68e9..fdac600 100644 (file)
@@ -2320,8 +2320,8 @@ ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \
 ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 R2_R1
 ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 R1_R2
 
-ovn-nbctl set Logical_Router R1 default_gw="20.0.0.2"
-ovn-nbctl set Logical_Router R2 default_gw="20.0.0.1"
+ovn-nbctl lr-route-add R1 "0.0.0.0/0" 20.0.0.2
+ovn-nbctl lr-route-add R2 "0.0.0.0/0" 20.0.0.1
 
 # Create logical port ls1-lp1 in ls1
 ovn-nbctl lsp-add ls1 ls1-lp1 \