From 7c35397c84dc4930e7c2be9d5dcef3a4955abbda Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Mon, 19 Aug 2013 14:45:02 -0700 Subject: [PATCH] ofproto: Start ofport allocation from the previous max after restart. 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 Acked-by: Ben Pfaff --- ofproto/ofproto.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 1e09c5662..4cb7ea8b3 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -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); + } } } } -- 2.43.0