/* ofport. */
static void ofport_destroy__(struct ofport *) OVS_EXCLUDED(ofproto_mutex);
static void ofport_destroy(struct ofport *, bool del);
+static inline bool ofport_is_internal(const struct ofport *);
static int update_port(struct ofproto *, const char *devname);
static int init_ports(struct ofproto *);
static uint64_t pick_fallback_dpid(void);
static void ofproto_destroy__(struct ofproto *);
static void update_mtu(struct ofproto *, struct ofport *);
+static void update_mtu_ofproto(struct ofproto *);
static void meter_delete(struct ofproto *, uint32_t first, uint32_t last);
static void meter_insert_rule(struct rule *);
static void
ofport_remove(struct ofport *ofport)
{
+ struct ofproto *p = ofport->ofproto;
+ bool is_internal = ofport_is_internal(ofport);
+
connmgr_send_port_status(ofport->ofproto->connmgr, NULL, &ofport->pp,
OFPPR_DELETE);
ofport_destroy(ofport, true);
+ if (!is_internal) {
+ update_mtu_ofproto(p);
+ }
}
/* If 'ofproto' contains an ofport named 'name', removes it from 'ofproto' and
return 0;
}
+static inline bool
+ofport_is_internal(const struct ofport *port)
+{
+ return !strcmp(netdev_get_type(port->netdev), "internal");
+}
+
/* Find the minimum MTU of all non-datapath devices attached to 'p'.
* Returns ETH_PAYLOAD_MAX or the minimum of the ports. */
static int
/* Skip any internal ports, since that's what we're trying to
* set. */
- if (!strcmp(netdev_get_type(netdev), "internal")) {
+ if (ofport_is_internal(ofport)) {
continue;
}
static void
update_mtu(struct ofproto *p, struct ofport *port)
{
- struct ofport *ofport;
struct netdev *netdev = port->netdev;
- int dev_mtu, old_min;
+ int dev_mtu;
if (netdev_get_mtu(netdev, &dev_mtu)) {
port->mtu = 0;
return;
}
- if (!strcmp(netdev_get_type(port->netdev), "internal")) {
+ if (ofport_is_internal(port)) {
if (dev_mtu > p->min_mtu) {
if (!netdev_set_mtu(port->netdev, p->min_mtu)) {
dev_mtu = p->min_mtu;
return;
}
- /* For non-internal port find new min mtu. */
- old_min = p->min_mtu;
port->mtu = dev_mtu;
+ /* For non-internal port find new min mtu. */
+ update_mtu_ofproto(p);
+}
+
+static void
+update_mtu_ofproto(struct ofproto *p)
+{
+ /* For non-internal port find new min mtu. */
+ struct ofport *ofport;
+ int old_min = p->min_mtu;
+
p->min_mtu = find_min_mtu(p);
if (p->min_mtu == old_min) {
return;
HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
struct netdev *netdev = ofport->netdev;
- if (!strcmp(netdev_get_type(netdev), "internal")) {
+ if (ofport_is_internal(ofport)) {
if (!netdev_set_mtu(netdev, p->min_mtu)) {
ofport->mtu = p->min_mtu;
}