summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
69b0983)
Internal device mtu does not influence mtu of other internal devices.
So skip MTU update to other devices when internal device mtu is changed.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
* widespread use, we will delete these interfaces. */
unsigned long int *vlan_bitmap; /* 4096-bit bitmap of in-use VLANs. */
bool vlans_changed; /* True if new VLANs are in use. */
* widespread use, we will delete these interfaces. */
unsigned long int *vlan_bitmap; /* 4096-bit bitmap of in-use VLANs. */
bool vlans_changed; /* True if new VLANs are in use. */
+ int min_mtu; /* Current MTU of non-internal ports. */
};
void ofproto_init_tables(struct ofproto *, int n_tables);
};
void ofproto_init_tables(struct ofproto *, int n_tables);
static uint64_t pick_datapath_id(const struct ofproto *);
static uint64_t pick_fallback_dpid(void);
static void ofproto_destroy__(struct ofproto *);
static uint64_t pick_datapath_id(const struct ofproto *);
static uint64_t pick_fallback_dpid(void);
static void ofproto_destroy__(struct ofproto *);
-static void set_internal_devs_mtu(struct ofproto *);
+static void update_mtu(struct ofproto *, struct ofport *);
/* unixctl. */
static void ofproto_unixctl_init(void);
/* unixctl. */
static void ofproto_unixctl_init(void);
hmap_init(&ofproto->deletions);
ofproto->vlan_bitmap = NULL;
ofproto->vlans_changed = false;
hmap_init(&ofproto->deletions);
ofproto->vlan_bitmap = NULL;
ofproto->vlans_changed = false;
+ ofproto->min_mtu = INT_MAX;
error = ofproto->ofproto_class->construct(ofproto);
if (error) {
error = ofproto->ofproto_class->construct(ofproto);
if (error) {
{
const char *netdev_name = netdev_get_name(netdev);
struct ofport *ofport;
{
const char *netdev_name = netdev_get_name(netdev);
struct ofport *ofport;
int error;
/* Create ofport. */
int error;
/* Create ofport. */
hmap_insert(&p->ports, &ofport->hmap_node, hash_int(ofport->ofp_port, 0));
shash_add(&p->port_by_name, netdev_name, ofport);
hmap_insert(&p->ports, &ofport->hmap_node, hash_int(ofport->ofp_port, 0));
shash_add(&p->port_by_name, netdev_name, ofport);
- if (!netdev_get_mtu(netdev, &dev_mtu)) {
- ofport->mtu = dev_mtu;
- set_internal_devs_mtu(p);
- } else {
- ofport->mtu = 0;
- }
/* Let the ofproto_class initialize its private data. */
error = p->ofproto_class->port_construct(ofport);
/* Let the ofproto_class initialize its private data. */
error = p->ofproto_class->port_construct(ofport);
port = ofproto_get_port(ofproto, ofproto_port.ofp_port);
if (port && !strcmp(netdev_get_name(port->netdev), name)) {
struct netdev *old_netdev = port->netdev;
port = ofproto_get_port(ofproto, ofproto_port.ofp_port);
if (port && !strcmp(netdev_get_name(port->netdev), name)) {
struct netdev *old_netdev = port->netdev;
/* 'name' hasn't changed location. Any properties changed? */
if (!ofport_equal(&port->pp, &pp)) {
ofport_modified(port, &pp);
}
/* 'name' hasn't changed location. Any properties changed? */
if (!ofport_equal(&port->pp, &pp)) {
ofport_modified(port, &pp);
}
- if (!netdev_get_mtu(netdev, &dev_mtu) &&
- port->mtu != dev_mtu) {
- port->mtu = dev_mtu;
- set_internal_devs_mtu(ofproto);
- }
+ update_mtu(ofproto, port);
/* Install the newly opened netdev in case it has changed.
* Don't close the old netdev yet in case port_modified has to
/* Install the newly opened netdev in case it has changed.
* Don't close the old netdev yet in case port_modified has to
return mtu ? mtu: ETH_PAYLOAD_MAX;
}
return mtu ? mtu: ETH_PAYLOAD_MAX;
}
-/* Set the MTU of all datapath devices on 'p' to the minimum of the
- * non-datapath ports. */
+/* Update MTU of all datapath devices on 'p' to the minimum of the
+ * non-datapath ports in event of 'port' added or changed. */
-set_internal_devs_mtu(struct ofproto *p)
+update_mtu(struct ofproto *p, struct ofport *port)
- int mtu = find_min_mtu(p);
+ struct netdev *netdev = port->netdev;
+ int dev_mtu, old_min;
+
+ if (netdev_get_mtu(netdev, &dev_mtu)) {
+ port->mtu = 0;
+ return;
+ }
+ if (!strcmp(netdev_get_type(port->netdev), "internal")) {
+ if (dev_mtu > p->min_mtu) {
+ if (!netdev_set_mtu(port->netdev, p->min_mtu)) {
+ dev_mtu = p->min_mtu;
+ }
+ }
+ port->mtu = dev_mtu;
+ return;
+ }
+
+ /* For non-internal port find new min mtu. */
+ old_min = p->min_mtu;
+ port->mtu = dev_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")) {
HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
struct netdev *netdev = ofport->netdev;
if (!strcmp(netdev_get_type(netdev), "internal")) {
- netdev_set_mtu(netdev, mtu);
- ofport->mtu = mtu;
+ if (!netdev_set_mtu(netdev, p->min_mtu)) {
+ ofport->mtu = p->min_mtu;
+ }