ofproto: Rework and fix bugs in port change detection.
The OpenFlow port change detection code in update_port() is supposed to
send out an OFPT_PORT_STATUS message whenever an OpenFlow port is added or
removed or changes in some way. This commit fixes a number of bugs that
have persisted until now.
First, if a port with a given name is removed from the datapath and a new
port with the same name but a different port number is added to the
datapath, then update_port() would report this as a port "modify" change.
Reporting this as a "modify" seems likely to confuse controllers, which
have no reason to realize that the old port was deleted and may not
understand why a port that has not been reported as added would be
modified. (This scenario is more likely than before, because the Linux
datapath implementation no longer quickly reuses port numbers. This
problem has actually been reported in testing.) This commit fixes the
problem by changing update_port() to report a "delete" of the old port
followed by an "add" of the new port.
Second, suppose that a datapath initially has "eth1" on port 1 and "eth2"
on port 2. Then, "eth1" gets removed and "eth2" is reassigned to port 1.
If update_port() is first passed "eth2", then the old implementation would
have sent out an OpenFlow "modify" notification instead of "delete"
followed by "add", which is the same as the previous scenario. But as a
further wrinkle, it would have failed to remove "eth1", which meant that we
ended up with two "ofports" with port number 1! This commit fixes this
problem too.
Reported-by: David Tsai <dtsai@nicira.com>
Bug #5466.
NIC-372.