diff mbox

[ovs-dev,ovn-ipv6,08/26] ovn: Remove 'default_gw' from logical router table.

Message ID 1468306616-125783-9-git-send-email-jpettit@ovn.org
State Accepted
Headers show

Commit Message

Justin Pettit July 12, 2016, 6:56 a.m. UTC
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>
---
 ovn/northd/ovn-northd.c | 35 -----------------------------------
 ovn/ovn-nb.ovsschema    |  5 ++---
 ovn/ovn-nb.xml          |  4 ----
 tests/ovn.at            |  4 ++--
 4 files changed, 4 insertions(+), 44 deletions(-)

Comments

Ben Pfaff July 12, 2016, 11:38 p.m. UTC | #1
On Mon, Jul 11, 2016 at 11:56:38PM -0700, Justin Pettit wrote:
> 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>
diff mbox

Patch

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index d0491ea..ed67dc5 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -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 */
 
diff --git a/ovn/ovn-nb.ovsschema b/ovn/ovn-nb.ovsschema
index ee7c2c6..5102948 100644
--- a/ovn/ovn-nb.ovsschema
+++ b/ovn/ovn-nb.ovsschema
@@ -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": {
@@ -105,7 +105,6 @@ 
                                             "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",
diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
index 5542ea4..1eeec22 100644
--- a/ovn/ovn-nb.xml
+++ b/ovn/ovn-nb.xml
@@ -729,10 +729,6 @@ 
       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
diff --git a/tests/ovn.at b/tests/ovn.at
index 63d68e9..fdac600 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -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 \