> +
> + Nexthop of this route, nexthop can be a IP address of neutron
> port, or
> + IP address which has been learnt by dynamic ARP.
>
Since this is OVN and we neutron is just one of the many upstream users, we
should avoid naming them.
Also, looking at the code, it looks like we currently only handle the case
where the nexthop is a router port's IP address. The documentation can be
updated if and when there is code to support something different.
There were a few other stylistic and codingstyle violations. I also made
changes to documentation to suit OVN's style. I am pasting the entire
incremental difference. If you are happy with it, I will apply this patch.
If not, please choose the ones you are happy with and respin.
# Create logical port foo1 in foo
diff --git a/AUTHORS b/AUTHORS
index 3f05a02..5290ef5 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -211,6 +211,7 @@ Steffen Gebert
steffen.gebert@informatik.uni-wuerzburg.de
Sten Spans sten@blinkenlights.nl
Stephane A. Sezer sas@cd80.net
Stephen Finucane stephen.finucane@intel.com
+Steve Ruan ruansx@cn.ibm.com
SUGYO Kazushi sugyo.org@gmail.com
Tadaaki Nagao nagao@stratosphere.co.jp
Terry Wilson twilson@redhat.com
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index ea1dd6b..9372d5a 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -1828,70 +1828,65 @@ add_route(struct hmap *lflows, const struct
ovn_port *op,
static void
build_static_route_flow(struct hmap *lflows, struct ovn_datapath *od,
- struct hmap *ports,
- const struct nbrec_logical_router_static_route *route)
+ struct hmap *ports,
+ const struct nbrec_logical_router_static_route
*route)
{
struct ovn_port *out_port, *op;
ovs_be32 prefix, next_hop, mask;
int len;
- /* verify nexthop */
+ /* Verify nexthop ip address. */
char *error = ip_parse_masked(route->nexthop, &next_hop, &mask);
if (error || mask != OVS_BE32_MAX) {
- static struct vlog_rate_limit rl
- = VLOG_RATE_LIMIT_INIT(5, 1);
- VLOG_WARN_RL(&rl, "bad next hop ip address %s",
- route->nexthop);
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
+ VLOG_WARN_RL(&rl, "bad next hop ip address %s", route->nexthop);
free(error);
return;
}
- /* verify prefix */
- error = ip_parse_masked(route->prefix, &prefix, &mask);
+ /* Verify IP prefix. */
+ error = ip_parse_masked(route->ip_prefix, &prefix, &mask);
if (error || !ip_is_cidr(mask)) {
- static struct vlog_rate_limit rl
- = VLOG_RATE_LIMIT_INIT(5, 1);
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
VLOG_WARN_RL(&rl, "bad 'network' in static routes %s",
- route->prefix);
+ route->ip_prefix);
free(error);
return;
}
- /* find the outgoing port */
+ /* Find the outgoing port. */
out_port = NULL;
len = 0;
- if (route->output_port){
+ if (route->output_port) {
out_port = ovn_port_find(ports, route->output_port);
- if (!out_port){
- static struct vlog_rate_limit rl
- = VLOG_RATE_LIMIT_INIT(5, 1);
+ if (!out_port) {
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
VLOG_WARN_RL(&rl, "bad 'out port' in static routes %s",
- route->output_port);
+ route->output_port);
return;
}
- }
- else{ /* output_port is not specified, then find the
- * router port with longest net mask match */
- for (int i = 0; i < od->nbr->n_ports; i++){
-
+ } else {
+ /* Since output_port is not specified, find the
+ * router port with longest prefix match */
+ for (int i = 0; i < od->nbr->n_ports; i++) {
struct nbrec_logical_router_port *lrp = od->nbr->ports[i];
op = ovn_port_find(ports, lrp->name);
- if (!op){ /* this should not happen */
+ if (!op) {
+ /* This should not happen. */
continue;
}
- if (op->network && !((op->network ^ next_hop) & op->mask)){
- if (ip_count_cidr_bits(op->mask) > len){
+ if (op->network && !((op->network ^ next_hop) & op->mask)) {
+ if (ip_count_cidr_bits(op->mask) > len) {
len = ip_count_cidr_bits(op->mask);
out_port = op;
}
}
}
- if (!out_port){
- static struct vlog_rate_limit rl
- = VLOG_RATE_LIMIT_INIT(5, 1);
- VLOG_WARN_RL(&rl, "no matched out port for next hop %s",
- route->nexthop);
+ if (!out_port) {
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
+ VLOG_WARN_RL(&rl, "no matched outport for next hop %s",
+ route->nexthop);
return;
}
}
@@ -2068,8 +2063,8 @@ build_lrouter_flows(struct hmap *datapaths, struct
hmap *ports,
continue;
}
- /* convert the routing table to flow */
- for (int i = 0; i < od->nbr->n_static_routes; i++){
+ /* Convert the static routes to flows. */
+ for (int i = 0; i < od->nbr->n_static_routes; i++) {
const struct nbrec_logical_router_static_route *route;
route = od->nbr->static_routes[i];
diff --git a/ovn/ovn-nb.ovsschema b/ovn/ovn-nb.ovsschema
index e67f903..8163f6a 100644
--- a/ovn/ovn-nb.ovsschema
+++ b/ovn/ovn-nb.ovsschema
@@ -1,7 +1,7 @@
{
"name": "OVN_Northbound",
"version": "2.1.1",
- "cksum": "1773273858 5105",
+ "cksum": "2615511875 5108",
"tables": {
"Logical_Switch": {
"columns": {
@@ -96,7 +96,7 @@
"isRoot": false},
"Logical_Router_Static_Route": {
"columns": {
- "prefix": {"type": "string"},
+ "ip_prefix": {"type": "string"},
"nexthop": {"type": "string"},
"output_port": {"type": {"key": "string", "min": 0, "max":
1}}},
"isRoot": false}
diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
index b7091c2..943b1a6 100644
--- a/ovn/ovn-nb.xml
+++ b/ovn/ovn-nb.xml
@@ -624,7 +624,7 @@