ofproto: Start ofport allocation from the previous max after restart.
authorGurucharan Shetty <gshetty@nicira.com>
Mon, 19 Aug 2013 21:45:02 +0000 (14:45 -0700)
committerGurucharan Shetty <gshetty@nicira.com>
Wed, 21 Aug 2013 21:24:17 +0000 (14:24 -0700)
We currently do not recycle ofport numbers from interfaces that are recently
deleted by maintaining the maximum allocated ofport value and
allocating new ofport numbers greater than the previous maximum.
But after a restart of ovs-vswitchd, we start again from ofport value of '1'.
This means that after a restart, we can immeditaley recycle the 'ofport'
value of the most recently deleted interface.

With this commit, during ovs-vswitchd initial configuration, we figure
out the previously allocated max ofport value. New interfaces get ofport
value that is greater than this.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto.c

index 1e09c56..4cb7ea8 100644 (file)
@@ -2103,6 +2103,10 @@ init_ports(struct ofproto *p)
             netdev = ofport_open(p, &ofproto_port, &pp);
             if (netdev) {
                 ofport_install(p, netdev, &pp);
+                if (ofproto_port.ofp_port < p->max_ports) {
+                    p->alloc_port_no = MAX(p->alloc_port_no,
+                                           ofproto_port.ofp_port);
+                }
             }
         }
     }