Skip to contentSkip to conversation

ofproto: Consider datapath_type when looking for internal ports.

PATCH In review Mark Kavanagh 1 participant 8 messages Aug 5, 2016 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 ofproto: Consider datapath_type when looking for internal ports.

From: Daniele Di Proietto <[email protected]>

Interfaces with type "internal" end up having a netdev with type "tap" in the dpif-netdev datapath, so a strcmp will fail to match internal interfaces.

We can translate the types with ofproto_port_open_type() before calling strcmp to fix this.

This fixes a minor issue where internal interfaces are considered non-internal in the userspace datapath for the purpose of adjusting the MTU.

---
 ofproto/ofproto.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
ofproto/ofproto.c +9 -7
index 8e59c69..088f91a 100644
@@ -220,7 +220,8 @@ static void learned_cookies_flush(struct ofproto *, struct ovs_list *dead_cookie
 /* 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 inline bool ofport_is_internal(const struct ofproto *,
+                                      const struct ofport *);
 
 static int update_port(struct ofproto *, const char *devname);
 static int init_ports(struct ofproto *);
@@ -2465,7 +2466,7 @@ static void
 ofport_remove(struct ofport *ofport)
 {
     struct ofproto *p = ofport->ofproto;
-    bool is_internal = ofport_is_internal(ofport);
+    bool is_internal = ofport_is_internal(p, ofport);
 
     connmgr_send_port_status(ofport->ofproto->connmgr, NULL, &ofport->pp,
                              OFPPR_DELETE);
@@ -2751,9 +2752,10 @@ init_ports(struct ofproto *p)
 }
 
 static inline bool
-ofport_is_internal(const struct ofport *port)
+ofport_is_internal(const struct ofproto *p, const struct ofport *port)
 {
-    return !strcmp(netdev_get_type(port->netdev), "internal");
+    return !strcmp(netdev_get_type(port->netdev),
+                   ofproto_port_open_type(p->type, "internal"));
 }
 
 /* Find the minimum MTU of all non-datapath devices attached to 'p'.
@@ -2770,7 +2772,7 @@ find_min_mtu(struct ofproto *p)
 
         /* Skip any internal ports, since that's what we're trying to
          * set. */
-        if (ofport_is_internal(ofport)) {
+        if (ofport_is_internal(p, ofport)) {
             continue;
         }
 
@@ -2797,7 +2799,7 @@ update_mtu(struct ofproto *p, struct ofport *port)
         port->mtu = 0;
         return;
     }
-    if (ofport_is_internal(port)) {
+    if (ofport_is_internal(p, port)) {
         if (dev_mtu > p->min_mtu) {
            if (!netdev_set_mtu(port->netdev, p->min_mtu)) {
                dev_mtu = p->min_mtu;
@@ -2827,7 +2829,7 @@ update_mtu_ofproto(struct ofproto *p)
     HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
         struct netdev *netdev = ofport->netdev;
 
-        if (ofport_is_internal(ofport)) {
+        if (ofport_is_internal(p, ofport)) {
             if (!netdev_set_mtu(netdev, p->min_mtu)) {
                 ofport->mtu = p->min_mtu;
             }
Signature · 1 line
1.9.3
#1 lore raw

PATCH 2/7 vswitchd: Introduce 'mtu_request' column in Interface.

From: Daniele Di Proietto <[email protected]>

The 'mtu_request' column can be used to set the MTU of a specific interface.

This column is useful because it will allow changing the MTU of DPDK devices (implemented in a future commit), which are not accessible outside the ovs-vswitchd process, but it can be used for kernel interfaces as well.

The current implementation of set_mtu() in netdev-dpdk is removed because it's broken. It will be reintroduced by a subsequent commit on this series.

---
 NEWS                       |  2 ++
 lib/netdev-dpdk.c          | 53 +---------------------------------------------
 vswitchd/bridge.c          |  9 ++++++++
 vswitchd/vswitch.ovsschema | 10 +++++++--
 vswitchd/vswitch.xml       | 52 +++++++++++++++++++++++++++++++++------------
 5 files changed, 58 insertions(+), 68 deletions(-)
NEWS +2 -0
index c2ed71d..ce10982 100644
@@ -101,6 +101,8 @@ Post-v2.5.0
    - ovs-pki: Changed message digest algorithm from SHA-1 to SHA-512 because
      SHA-1 is no longer secure and some operating systems have started to
      disable it in OpenSSL.
+   - Add 'mtu_request' column to the Interface table. It can be used to
+     configure the MTU of non-internal ports.
 
 
 v2.5.0 - 26 Feb 2016
lib/netdev-dpdk.c +1 -52

65 lines not on this page · raw message

vswitchd/bridge.c +9 -0
index ddf1fe5..397be70 100644
@@ -775,6 +775,15 @@ bridge_delete_or_reconfigure_ports(struct bridge *br)
             goto delete;
         }
 
+        if (iface->cfg->n_mtu_request == 1
+            && strcmp(iface->type,
+                      ofproto_port_open_type(br->type, "internal"))) {
+            /* Try to set the MTU to the requested value.  This is not done
+             * for internal interfaces, since their MTU is decided by the
+             * ofproto module, based on other ports in the bridge. */
+            netdev_set_mtu(iface->netdev, *iface->cfg->mtu_request);
+        }
+
         /* If the requested OpenFlow port for 'iface' changed, and it's not
          * already the correct port, then we might want to temporarily delete
          * this interface, so we can add it back again with the new OpenFlow
vswitchd/vswitch.ovsschema +8 -2
index 32fdf28..8966803 100644
@@ -1,6 +1,6 @@
 {"name": "Open_vSwitch",
- "version": "7.13.0",
- "cksum": "889248633 22774",
+ "version": "7.14.0",
+ "cksum": "3974332717 22936",
  "tables": {
    "Open_vSwitch": {
      "columns": {
@@ -321,6 +321,12 @@
        "mtu": {
          "type": {"key": "integer", "min": 0, "max": 1},
          "ephemeral": true},
+       "mtu_request": {
+         "type": {
+           "key": {"type": "integer",
+                   "minInteger": 1},
+           "min": 0,
+           "max": 1}},
        "error": {
          "type": {"key": "string", "min": 0, "max": 1}}},
      "indexes": [["name"]]},
vswitchd/vswitch.xml +38 -14

64 lines not on this page · raw message

Signature · 1 line
1.9.3
#2 lore raw

PATCH 3/7 netdev: Pass 'netdev_class' to ->run() and ->wait().

In reply to Mark Kavanagh

From: Daniele Di Proietto <[email protected]>

This will allow run() and wait() methods to be shared between different classes and still perform class-specific work.

---
 lib/netdev-bsd.c      |  6 +++---
 lib/netdev-dummy.c    |  4 ++--
 lib/netdev-linux.c    |  6 +++---
 lib/netdev-provider.h | 14 ++++++++++----
 lib/netdev-vport.c    |  4 ++--
 lib/netdev.c          |  4 ++--
 6 files changed, 22 insertions(+), 16 deletions(-)
lib/netdev-bsd.c +3 -3
index 2bba0ed..75a330b 100644
@@ -146,7 +146,7 @@ static void ifr_set_flags(struct ifreq *, int flags);
 static int af_link_ioctl(unsigned long command, const void *arg);
 #endif
 
-static void netdev_bsd_run(void);
+static void netdev_bsd_run(const struct netdev_class *);
 static int netdev_bsd_get_mtu(const struct netdev *netdev_, int *mtup);
 
 static bool
@@ -180,7 +180,7 @@ netdev_get_kernel_name(const struct netdev *netdev)
  * interface status changes, and eventually calls all the user callbacks.
  */
 static void
-netdev_bsd_run(void)
+netdev_bsd_run(const struct netdev_class *netdev_class OVS_UNUSED)
 {
     rtbsd_notifier_run();
 }
@@ -190,7 +190,7 @@ netdev_bsd_run(void)
  * be called.
  */
 static void
-netdev_bsd_wait(void)
+netdev_bsd_wait(const struct netdev_class *netdev_class OVS_UNUSED)
 {
     rtbsd_notifier_wait();
 }
lib/netdev-dummy.c +2 -2
index a950409..2a6aa56 100644
@@ -622,7 +622,7 @@ dummy_netdev_get_conn_state(struct dummy_packet_conn *conn)
 }
 
 static void
-netdev_dummy_run(void)
+netdev_dummy_run(const struct netdev_class *netdev_class OVS_UNUSED)
 {
     struct netdev_dummy *dev;
 
@@ -636,7 +636,7 @@ netdev_dummy_run(void)
 }
 
 static void
-netdev_dummy_wait(void)
+netdev_dummy_wait(const struct netdev_class *netdev_class OVS_UNUSED)
 {
     struct netdev_dummy *dev;
 
lib/netdev-linux.c +3 -3
index fa37bcf..1b5f7c1 100644
@@ -526,7 +526,7 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
  * changes in the device miimon status, so we can use atomic_count. */
 static atomic_count miimon_cnt = ATOMIC_COUNT_INIT(0);
 
-static void netdev_linux_run(void);
+static void netdev_linux_run(const struct netdev_class *);
 
 static int netdev_linux_do_ethtool(const char *name, struct ethtool_cmd *,
                                    int cmd, const char *cmd_name);
@@ -623,7 +623,7 @@ netdev_linux_miimon_enabled(void)
 }
 
 static void
-netdev_linux_run(void)
+netdev_linux_run(const struct netdev_class *netdev_class OVS_UNUSED)
 {
     struct nl_sock *sock;
     int error;
@@ -697,7 +697,7 @@ netdev_linux_run(void)
 }
 
 static void
-netdev_linux_wait(void)
+netdev_linux_wait(const struct netdev_class *netdev_class OVS_UNUSED)
 {
     struct nl_sock *sock;
 
lib/netdev-provider.h +10 -4
index ae390cb..5bcfeba 100644
@@ -236,15 +236,21 @@ struct netdev_class {
     int (*init)(void);
 
     /* Performs periodic work needed by netdevs of this class.  May be null if
-     * no periodic work is necessary. */
-    void (*run)(void);
+     * no periodic work is necessary.
+     *
+     * 'netdev_class' points to the class.  It is useful in case the same
+     * function is used to implement different classes. */
+    void (*run)(const struct netdev_class *netdev_class);
 
     /* Arranges for poll_block() to wake up if the "run" member function needs
      * to be called.  Implementations are additionally required to wake
      * whenever something changes in any of its netdevs which would cause their
      * ->change_seq() function to change its result.  May be null if nothing is
-     * needed here. */
-    void (*wait)(void);
+     * needed here.
+     *
+     * 'netdev_class' points to the class.  It is useful in case the same
+     * function is used to implement different classes. */
+    void (*wait)(const struct netdev_class *netdev_class);
 
 /* ## ---------------- ## */
 /* ## netdev Functions ## */
lib/netdev-vport.c +2 -2
index 87a30f8..7eabd2c 100644
@@ -321,7 +321,7 @@ netdev_vport_update_flags(struct netdev *netdev OVS_UNUSED,
 }
 
 static void
-netdev_vport_run(void)
+netdev_vport_run(const struct netdev_class *netdev_class OVS_UNUSED)
 {
     uint64_t seq;
 
@@ -334,7 +334,7 @@ netdev_vport_run(void)
 }
 
 static void
-netdev_vport_wait(void)
+netdev_vport_wait(const struct netdev_class *netdev_class OVS_UNUSED)
 {
     uint64_t seq;
 
lib/netdev.c +2 -2
index 75bf1cb..589d37c 100644
@@ -160,7 +160,7 @@ netdev_run(void)
     struct netdev_registered_class *rc;
     CMAP_FOR_EACH (rc, cmap_node, &netdev_classes) {
         if (rc->class->run) {
-            rc->class->run();
+            rc->class->run(rc->class);
         }
     }
 }
@@ -178,7 +178,7 @@ netdev_wait(void)
     struct netdev_registered_class *rc;
     CMAP_FOR_EACH (rc, cmap_node, &netdev_classes) {
         if (rc->class->wait) {
-            rc->class->wait();
+            rc->class->wait(rc->class);
         }
     }
 }
Signature · 1 line
1.9.3
#3 lore raw

PATCH 4/7 netdev-dummy: Add dummy-internal class.

In reply to Mark Kavanagh

From: Daniele Di Proietto <[email protected]>

"internal" netdevs are treated specially in OVS (e.g. for MTU), but the dummy datapath remaps both "system" and "internal" devices to the same "dummy" netdev class, so there's no way to discern those in tests.

This commit adds a new "dummy-internal" netdev type, which will be used by the dummy datapath for internal ports, so that other parts of the code can understand which ports are internal just by looking at the netdev object.

The alternative solution, using the original interface type ("internal") instead of the translated netdev type ("dummy"), is harder to implement, because in so many places only the netdev object is available.

---
 lib/dpif-netdev.c             |  2 +-
 lib/netdev-dummy.c            | 14 ++++++++++++--
 tests/bridge.at               |  6 +++---
 tests/dpctl.at                | 12 ++++++------
 tests/mpls-xlate.at           |  4 ++--
 tests/netdev-type.at          |  2 +-
 tests/ofproto-dpif.at         | 18 +++++++++---------
 tests/ovs-vswitchd.at         |  6 +++---
 tests/pmd.at                  |  8 ++++----
 tests/tunnel-push-pop-ipv6.at |  4 ++--
 tests/tunnel-push-pop.at      |  4 ++--
 tests/tunnel.at               | 28 ++++++++++++++--------------
 12 files changed, 59 insertions(+), 49 deletions(-)
lib/dpif-netdev.c +1 -1
index e39362e..6f2e07d 100644
@@ -888,7 +888,7 @@ static const char *
 dpif_netdev_port_open_type(const struct dpif_class *class, const char *type)
 {
     return strcmp(type, "internal") ? type
-                  : dpif_netdev_class_is_dummy(class) ? "dummy"
+                  : dpif_netdev_class_is_dummy(class) ? "dummy-internal"
                   : "tap";
 }
 
lib/netdev-dummy.c +12 -2
index 2a6aa56..92af15f 100644
@@ -622,12 +622,15 @@ dummy_netdev_get_conn_state(struct dummy_packet_conn *conn)
 }
 
 static void
-netdev_dummy_run(const struct netdev_class *netdev_class OVS_UNUSED)
+netdev_dummy_run(const struct netdev_class *netdev_class)
 {
     struct netdev_dummy *dev;
 
     ovs_mutex_lock(&dummy_list_mutex);
     LIST_FOR_EACH (dev, list_node, &dummy_list) {
+        if (netdev_get_class(&dev->up) != netdev_class) {
+            continue;
+        }
         ovs_mutex_lock(&dev->mutex);
         dummy_packet_conn_run(dev);
         ovs_mutex_unlock(&dev->mutex);
@@ -636,12 +639,15 @@ netdev_dummy_run(const struct netdev_class *netdev_class OVS_UNUSED)
 }
 
 static void
-netdev_dummy_wait(const struct netdev_class *netdev_class OVS_UNUSED)
+netdev_dummy_wait(const struct netdev_class *netdev_class)
 {
     struct netdev_dummy *dev;
 
     ovs_mutex_lock(&dummy_list_mutex);
     LIST_FOR_EACH (dev, list_node, &dummy_list) {
+        if (netdev_get_class(&dev->up) != netdev_class) {
+            continue;
+        }
         ovs_mutex_lock(&dev->mutex);
         dummy_packet_conn_wait(&dev->conn);
         ovs_mutex_unlock(&dev->mutex);
@@ -1380,6 +1386,9 @@ netdev_dummy_update_flags(struct netdev *netdev_,
 static const struct netdev_class dummy_class =
     NETDEV_DUMMY_CLASS("dummy", false, NULL);
 
+static const struct netdev_class dummy_internal_class =
+    NETDEV_DUMMY_CLASS("dummy-internal", false, NULL);
+
 static const struct netdev_class dummy_pmd_class =
     NETDEV_DUMMY_CLASS("dummy-pmd", true,
                        netdev_dummy_reconfigure);
@@ -1751,6 +1760,7 @@ netdev_dummy_register(enum dummy_level level)
         netdev_dummy_override("system");
     }
     netdev_register_provider(&dummy_class);
+    netdev_register_provider(&dummy_internal_class);
     netdev_register_provider(&dummy_pmd_class);
 
     netdev_vport_tunnel_register();
tests/bridge.at +3 -3
index 37c55ba..3dbabe5 100644
@@ -12,7 +12,7 @@ add_of_ports br0 1 2
 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (dummy)
 		p2 2/2: (dummy)
 ])
@@ -23,7 +23,7 @@ AT_CHECK([ovs-appctl dpctl/del-if dummy@ovs-dummy p1])
 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p2 2/2: (dummy)
 ])
 
@@ -32,7 +32,7 @@ AT_CHECK([ovs-vsctl del-port p2])
 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (dummy)
 ])
 OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
tests/dpctl.at +6 -6
index b6d5dd6..8c761c8 100644
@@ -23,14 +23,14 @@ AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
 dummy@br0:
 	lookups: hit:0 missed:0 lost:0
 	flows: 0
-	port 0: br0 (dummy)
+	port 0: br0 (dummy-internal)
 ])
 AT_CHECK([ovs-appctl dpctl/add-if dummy@br0 vif1.0,type=dummy,port_no=5])
 AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
 dummy@br0:
 	lookups: hit:0 missed:0 lost:0
 	flows: 0
-	port 0: br0 (dummy)
+	port 0: br0 (dummy-internal)
 	port 5: vif1.0 (dummy)
 ])
 AT_CHECK([ovs-appctl dpctl/add-if dummy@br0 vif1.0,type=dummy], [2], [],
@@ -44,9 +44,9 @@ AT_CHECK([ovs-appctl dpctl/set-if dummy@br0 vif1.0,type=system], [2], [],
   [ovs-vswitchd: vif1.0: can't change type from dummy to system
 ovs-appctl: ovs-vswitchd: server returned an error
 ])
-AT_CHECK([ovs-appctl dpctl/set-if dummy@br0 br0,type=dummy], [0])
+AT_CHECK([ovs-appctl dpctl/set-if dummy@br0 br0,type=dummy-internal], [0])
 AT_CHECK([ovs-appctl dpctl/set-if dummy@br0 br0,type=internal], [2], [],
-  [ovs-vswitchd: br0: can't change type from dummy to internal
+  [ovs-vswitchd: br0: can't change type from dummy-internal to internal
 ovs-appctl: ovs-vswitchd: server returned an error
 ])
 AT_CHECK([ovs-appctl dpctl/del-if dummy@br0 vif1.0])
@@ -54,7 +54,7 @@ AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
 dummy@br0:
 	lookups: hit:0 missed:0 lost:0
 	flows: 0
-	port 0: br0 (dummy)
+	port 0: br0 (dummy-internal)
 ])
 AT_CHECK([ovs-appctl dpctl/del-if dummy@br0 vif1.0], [2], [],
   [ovs-vswitchd: no port named vif1.0
@@ -64,7 +64,7 @@ AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
 dummy@br0:
 	lookups: hit:0 missed:0 lost:0
 	flows: 0
-	port 0: br0 (dummy)
+	port 0: br0 (dummy-internal)
 ])
 AT_CHECK([ovs-appctl dpctl/del-if dummy@br0 nonexistent], [2], [],
   [ovs-vswitchd: no port named nonexistent
tests/mpls-xlate.at +2 -2
index a9a3cf5..598a05a 100644
@@ -16,11 +16,11 @@ OVS_VSWITCHD_START(
 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p0 1/1: (dummy)
 		p1 2/none: (patch: peer=p2)
 	br1:
-		br1 65534/101: (dummy)
+		br1 65534/101: (dummy-internal)
 		p2 1/none: (patch: peer=p1)
 ])
 
tests/netdev-type.at +1 -1
index 184031b..5450f33 100644
@@ -9,7 +9,7 @@ add_of_ports br0 1
 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (dummy)
 ])
 #
tests/ofproto-dpif.at +9 -9
index 2c35fe1..a46fc81 100644
@@ -5657,7 +5657,7 @@ OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (gre: key=5, local_ip=2.2.2.2, remote_ip=1.1.1.1)
 		p2 2/2: (dummy)
 ])
@@ -5829,10 +5829,10 @@ AT_CHECK([ovs-vsctl -- add-port int-br t1 -- set Interface t1 type=gre \
 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p0 1/1: (dummy: ifindex=1010)
 	int-br:
-		int-br 65534/2: (dummy)
+		int-br 65534/2: (dummy-internal)
 		t1 4/4: (gre: key=456, remote_ip=1.1.2.92)
 		vm1 5/3: (dummy: ifindex=2011)
 ])
@@ -6573,11 +6573,11 @@ add_of_ports br1 3
 AT_CHECK([ovs-appctl dpif/show | sed 's/\(dummy-pmd: \).*)/\1<cleared>)/'], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (dummy-pmd: <cleared>)
 		p2 2/2: (dummy-pmd: <cleared>)
 	br1:
-		br1 65534/101: (dummy)
+		br1 65534/101: (dummy-internal)
 		p3 3/3: (dummy)
 ])
 OVS_VSWITCHD_STOP
@@ -6757,11 +6757,11 @@ sleep 1  # wait for log writer
 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
 dummy@ovs-dummy: hit:13 missed:2
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p2 2/2: (dummy)
 		pbr0 1/none: (patch: peer=pbr1)
 	br1:
-		br1 65534/101: (dummy)
+		br1 65534/101: (dummy-internal)
 		p3 3/3: (dummy)
 		pbr1 1/none: (patch: peer=pbr0)
 ])
@@ -6822,11 +6822,11 @@ OVS_WAIT_UNTIL([test `grep flow_add ovs-vswitchd.log | wc -l` -ge 1])
 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:1
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p2 2/2: (dummy)
 		pbr0 1/none: (patch: peer=pbr1)
 	br1:
-		br1 65534/101: (dummy)
+		br1 65534/101: (dummy-internal)
 		p3 3/3: (dummy)
 		pbr1 1/none: (patch: peer=pbr0)
 ])
tests/ovs-vswitchd.at +3 -3
index 21c14d2..a4e6a59 100644
@@ -186,9 +186,9 @@ AT_CHECK([ovs-vsctl add-port br0 p1  -- set interface p1 type=internal])
 
 dnl ovs-vswitchd should still 'see' ovsdb change with the 'monitor' method
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
-		p0 1/1: (dummy)
-		p1 2/2: (dummy)
+		br0 65534/100: (dummy-internal)
+		p0 1/1: (dummy-internal)
+		p1 2/2: (dummy-internal)
 ])
 OVS_VSWITCHD_STOP
 AT_CLEANUP
tests/pmd.at +4 -4
index 2188ea1..5a10255 100644
@@ -70,7 +70,7 @@ pmd thread numa_id <cleared> core_id <cleared>:
 AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p0 1/1: (dummy-pmd: configured_rx_queues=1, configured_tx_queues=<cleared>, requested_rx_queues=1, requested_tx_queues=<cleared>)
 ])
 
@@ -88,7 +88,7 @@ AT_CHECK([ovs-vsctl set interface p0 options:n_rxq=8])
 AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p0 1/1: (dummy-pmd: configured_rx_queues=8, configured_tx_queues=<cleared>, requested_rx_queues=8, requested_tx_queues=<cleared>)
 ])
 
@@ -112,7 +112,7 @@ CHECK_PMD_THREADS_CREATED()
 AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p0 1/1: (dummy-pmd: configured_rx_queues=8, configured_tx_queues=<cleared>, requested_rx_queues=8, requested_tx_queues=<cleared>)
 ])
 
@@ -164,7 +164,7 @@ sleep 1
 AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p0 7/1: (dummy-pmd: configured_rx_queues=4, configured_tx_queues=<cleared>, requested_rx_queues=4, requested_tx_queues=<cleared>)
 ])
 
tests/tunnel-push-pop-ipv6.at +2 -2
index e88776c..e47eb50 100644
@@ -17,10 +17,10 @@ AT_CHECK([ovs-vsctl add-port int-br t2 -- set Interface t2 type=vxlan \
 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p0 1/1: (dummy)
 	int-br:
-		int-br 65534/2: (dummy)
+		int-br 65534/2: (dummy-internal)
 		t1 3/3: (gre: key=456, remote_ip=2001:cafe::92)
 		t2 2/4789: (vxlan: key=123, remote_ip=2001:cafe::92)
 		t3 4/4789: (vxlan: csum=true, out_key=flow, remote_ip=2001:cafe::93)
tests/tunnel-push-pop.at +2 -2
index 40c2058..ee29594 100644
@@ -17,10 +17,10 @@ AT_CHECK([ovs-vsctl add-port int-br t2 -- set Interface t2 type=vxlan \
 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
 dummy@ovs-dummy: hit:0 missed:0
 	br0:
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p0 1/1: (dummy)
 	int-br:
-		int-br 65534/2: (dummy)
+		int-br 65534/2: (dummy-internal)
 		t1 3/3: (gre: key=456, remote_ip=1.1.2.92)
 		t2 2/4789: (vxlan: key=123, remote_ip=1.1.2.92)
 		t3 4/4789: (vxlan: csum=true, out_key=flow, remote_ip=1.1.2.93)
tests/tunnel.at +14 -14
index 15ae5cf..477517e 100644
@@ -16,7 +16,7 @@ OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (gre: remote_ip=1.1.1.1)
 		p2 2/1: (gre: local_ip=2.2.2.2, remote_ip=1.1.1.1)
 		p3 3/1: (gre: remote_ip=2.2.2.2)
@@ -39,7 +39,7 @@ AT_CHECK([ovs-vsctl set Interface p2 type=gre options:local_ip=2.2.2.3 \
           options:df_default=false options:ttl=1 options:csum=true \
           -- set Interface p3 type=vxlan])
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (gre: remote_ip=1.1.1.1)
 		p2 2/1: (gre: csum=true, df_default=false, local_ip=2.2.2.3, remote_ip=1.1.1.1, ttl=1)
 		p3 3/4789: (vxlan: remote_ip=2.2.2.2)
@@ -74,7 +74,7 @@ actions=2
 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (gre: remote_ip=1.1.1.1)
 		p2 2/2: (dummy)
 ])
@@ -123,7 +123,7 @@ OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (gre: key=5, local_ip=2.2.2.2, remote_ip=1.1.1.1)
 		p2 2/2: (dummy)
 ])
@@ -276,7 +276,7 @@ OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (gre: remote_ip=1.1.1.1, tos=inherit, ttl=inherit)
 		p2 2/2: (dummy)
 ])
@@ -319,7 +319,7 @@ OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (gre: key=flow, remote_ip=1.1.1.1)
 		p2 2/1: (gre: key=flow, remote_ip=2.2.2.2)
 		p3 3/1: (gre: key=flow, remote_ip=3.3.3.3)
@@ -352,7 +352,7 @@ OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (gre: key=1, remote_ip=1.1.1.1)
 		p2 2/1: (gre: in_key=2, out_key=3, remote_ip=1.1.1.1)
 		p3 3/1: (gre: out_key=5, remote_ip=1.1.1.1)
@@ -405,7 +405,7 @@ OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/1: (gre: key=flow, remote_ip=1.1.1.1)
 		p2 2/1: (gre: key=3, remote_ip=3.3.3.3)
 		p3 3/3: (dummy)
@@ -441,7 +441,7 @@ OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
                     options:remote_ip=1.1.1.1 ofport_request=1 options:dst_port=5000])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/5000: (geneve: dst_port=5000, remote_ip=1.1.1.1)
 ])
 
@@ -453,7 +453,7 @@ OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
                     options:remote_ip=1.1.1.1 ofport_request=1])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/4789: (vxlan: remote_ip=1.1.1.1)
 ])
 
@@ -465,7 +465,7 @@ OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=lisp \
                     options:remote_ip=1.1.1.1 ofport_request=1])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/4341: (lisp: remote_ip=1.1.1.1)
 ])
 
@@ -477,7 +477,7 @@ OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
                     options:remote_ip=1.1.1.1 ofport_request=1 options:dst_port=4341])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/4341: (vxlan: dst_port=4341, remote_ip=1.1.1.1)
 ])
 
@@ -486,7 +486,7 @@ dnl change UDP port
 AT_CHECK([ovs-vsctl -- set Interface p1 options:dst_port=5000])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/5000: (vxlan: dst_port=5000, remote_ip=1.1.1.1)
 ])
 
@@ -495,7 +495,7 @@ dnl change UDP port to default
 AT_CHECK([ovs-vsctl -- set Interface p1 options:dst_port=4789])
 
 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
-		br0 65534/100: (dummy)
+		br0 65534/100: (dummy-internal)
 		p1 1/4789: (vxlan: remote_ip=1.1.1.1)
 ])
 OVS_VSWITCHD_STOP
Signature · 1 line
1.9.3
#4 lore raw

PATCH 5/7 tests: Add a new MTU test.

In reply to Mark Kavanagh

From: Daniele Di Proietto <[email protected]>

Also, netdev-dummy needs to call netdev_change_seq_changed() in set_mtu().

---
 lib/netdev-dummy.c    |  5 ++++-
 tests/ofproto-dpif.at | 30 ++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
lib/netdev-dummy.c +4 -1
index 92af15f..c8f82b7 100644
@@ -1155,7 +1155,10 @@ netdev_dummy_set_mtu(const struct netdev *netdev, int mtu)
     struct netdev_dummy *dev = netdev_dummy_cast(netdev);
 
     ovs_mutex_lock(&dev->mutex);
-    dev->mtu = mtu;
+    if (dev->mtu != mtu) {
+        dev->mtu = mtu;
+        netdev_change_seq_changed(netdev);
+    }
     ovs_mutex_unlock(&dev->mutex);
 
     return 0;
tests/ofproto-dpif.at +30 -0
index a46fc81..3638063 100644
@@ -8859,3 +8859,33 @@ n_packets=0
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([ofproto - set mtu])
+OVS_VSWITCHD_START
+
+add_of_ports br0 1
+
+# Check that initial MTU is 1500 for 'br0' and 'p1'.
+AT_CHECK([ovs-vsctl get Interface br0 mtu], [0], [dnl
+1500
+])
+AT_CHECK([ovs-vsctl get Interface p1 mtu], [0], [dnl
+1500
+])
+
+# Request new MTU for 'p1'
+AT_CHECK([ovs-vsctl set Interface p1 mtu_request=1600])
+
+# Check that the new MTU is applied
+AT_CHECK([ovs-vsctl --timeout=10 wait-until Interface p1 mtu=1600])
+# The internal port 'br0' should have the same MTU value as p1, becase it's
+# the new bridge minimum.
+AT_CHECK([ovs-vsctl --timeout=10 wait-until Interface br0 mtu=1600])
+
+AT_CHECK([ovs-vsctl del-port br0 p1])
+
+# When 'p1' is deleted, the internal port should return to the default MTU
+AT_CHECK([ovs-vsctl --timeout=10 wait-until Interface br0 mtu=1500])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
Signature · 1 line
1.9.3
#5 lore raw

PATCH 6/7 netdev: Make netdev_set_mtu() netdev parameter non-const.

In reply to Mark Kavanagh

From: Daniele Di Proietto <[email protected]>

Every provider silently drops the const attribute when converting the parameter to the appropriate subclass. Might as well drop the const attribute from the parameter, since this is a "set" function.

---
v2->v1: add missing 'Signed-off-by' field in commit message.

 lib/netdev-dummy.c    | 2 +-
 lib/netdev-linux.c    | 2 +-
 lib/netdev-provider.h | 2 +-
 lib/netdev.c          | 2 +-
 lib/netdev.h          | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
lib/netdev-dummy.c +1 -1
index c8f82b7..dec1a8e 100644
@@ -1150,7 +1150,7 @@ netdev_dummy_get_mtu(const struct netdev *netdev, int *mtup)
 }
 
 static int
-netdev_dummy_set_mtu(const struct netdev *netdev, int mtu)
+netdev_dummy_set_mtu(struct netdev *netdev, int mtu)
 {
     struct netdev_dummy *dev = netdev_dummy_cast(netdev);
 
lib/netdev-linux.c +1 -1
index 1b5f7c1..20b5cc7 100644
@@ -1382,7 +1382,7 @@ netdev_linux_get_mtu(const struct netdev *netdev_, int *mtup)
  * networking ioctl interface.
  */
 static int
-netdev_linux_set_mtu(const struct netdev *netdev_, int mtu)
+netdev_linux_set_mtu(struct netdev *netdev_, int mtu)
 {
     struct netdev_linux *netdev = netdev_linux_cast(netdev_);
     struct ifreq ifr;
lib/netdev-provider.h +1 -1
index 5bcfeba..cd04ae9 100644
@@ -389,7 +389,7 @@ struct netdev_class {
      * If 'netdev' does not have an MTU (e.g. as some tunnels do not), then
      * this function should return EOPNOTSUPP.  This function may be set to
      * null if it would always return EOPNOTSUPP. */
-    int (*set_mtu)(const struct netdev *netdev, int mtu);
+    int (*set_mtu)(struct netdev *netdev, int mtu);
 
     /* Returns the ifindex of 'netdev', if successful, as a positive number.
      * On failure, returns a negative errno value.
lib/netdev.c +1 -1
index 589d37c..5cf8bbb 100644
@@ -869,7 +869,7 @@ netdev_get_mtu(const struct netdev *netdev, int *mtup)
  * MTU (as e.g. some tunnels do not).  On other failure, returns a positive
  * errno value. */
 int
-netdev_set_mtu(const struct netdev *netdev, int mtu)
+netdev_set_mtu(struct netdev *netdev, int mtu)
 {
     const struct netdev_class *class = netdev->netdev_class;
     int error;
lib/netdev.h +1 -1
index dc7ede8..d8ec627 100644
@@ -132,7 +132,7 @@ const char *netdev_get_name(const struct netdev *);
 const char *netdev_get_type(const struct netdev *);
 const char *netdev_get_type_from_name(const char *);
 int netdev_get_mtu(const struct netdev *, int *mtup);
-int netdev_set_mtu(const struct netdev *, int mtu);
+int netdev_set_mtu(struct netdev *, int mtu);
 int netdev_get_ifindex(const struct netdev *);
 int netdev_set_tx_multiq(struct netdev *, unsigned int n_txq);
 
Signature · 1 line
1.9.3
#6 lore raw

PATCH 7/7 netdev-dpdk: add support for Jumbo Frames

In reply to Mark Kavanagh

Add support for Jumbo Frames to DPDK-enabled port types, using single-segment-mbufs.

Using this approach, the amount of memory allocated to each mbuf to store frame data is increased to a value greater than 1518B (typical Ethernet maximum frame length). The increased space available in the mbuf means that an entire Jumbo Frame of a specific size can be carried in a single mbuf, as opposed to partitioning it across multiple mbuf segments.

The amount of space allocated to each mbuf to hold frame data is defined dynamically by the user with ovs-vsctl, via the 'mtu_request' parameter.

---

Previous: http://openvswitch.org/pipermail/dev/2016-July/076845.html

v2->v1:
- rebase to HEAD of master
- fall back to previous 'good' MTU if reconfigure fails
- introduce new field 'last_mtu' in struct netdev-dpdk to facilitate fall-back
- rename 'mtu_request' to 'requested_mtu' in struct netdev_dpdk
- remove rebasing artifact in INSTALL.DPDK-Advanced.md
- remove superflous variable in dpdk_mp_configure
- fix minor coding style infraction

 INSTALL.DPDK-ADVANCED.md |  58 ++++++++++++++++-
 INSTALL.DPDK.md          |   1 -
 NEWS                     |   1 +
 lib/netdev-dpdk.c        | 165 ++++++++++++++++++++++++++++++++++++++++-------
 4 files changed, 197 insertions(+), 28 deletions(-)
INSTALL.DPDK-ADVANCED.md +55 -3
index 0ab43d4..5e758ce 100755
@@ -1,5 +1,5 @@
 OVS DPDK ADVANCED INSTALL GUIDE
-=================================
+===============================
 
 ## Contents
 
@@ -12,7 +12,8 @@ OVS DPDK ADVANCED INSTALL GUIDE
 7. [QOS](#qos)
 8. [Rate Limiting](#rl)
 9. [Flow Control](#fc)
-10. [Vsperf](#vsperf)
+10. [Jumbo Frames](#jumbo)
+11. [Vsperf](#vsperf)
 
 ## <a name="overview"></a> 1. Overview
 
@@ -862,7 +863,58 @@ respective parameter. To disable the flow control at tx side,
 
 `ovs-vsctl set Interface dpdk0 options:tx-flow-ctrl=false`
 
-## <a name="vsperf"></a> 10. Vsperf
+## <a name="jumbo"></a> 10. Jumbo Frames
+
+By default, DPDK ports are configured with standard Ethernet MTU (1500B). To
+enable Jumbo Frames support for a DPDK port, change the Interface's `mtu_request`
+attribute to a sufficiently large value.
+
+e.g. Add a DPDK Phy port with MTU of 9000:
+
+`ovs-vsctl add-port br0 dpdk0 -- set Interface dpdk0 type=dpdk -- set Interface dpdk0 mtu_request=9000`
+
+e.g. Change the MTU of an existing port to 6200:
+
+`ovs-vsctl set Interface dpdk0 mtu_request=6200`
+
+When Jumbo Frames are enabled, the size of a DPDK port's mbuf segments are
+increased, such that a full Jumbo Frame of a specific size may be accommodated
+within a single mbuf segment.
+
+Jumbo frame support has been validated against 9728B frames (largest frame size
+supported by Fortville NIC), using the DPDK `i40e` driver, but larger frames
+(particularly in use cases involving East-West traffic only), and other DPDK NIC
+drivers may be supported.
+
+### 9.1 vHost Ports and Jumbo Frames
+
+Some additional configuration is needed to take advantage of jumbo frames with
+vhost ports:
+
+    1. `mergeable buffers` must be enabled for vHost ports, as demonstrated in
+        the QEMU command line snippet below:
+
+        ```
+        '-netdev type=vhost-user,id=mynet1,chardev=char0,vhostforce \'
+        '-device virtio-net-pci,mac=00:00:00:00:00:01,netdev=mynet1,mrg_rxbuf=on'
+        ```
+
+    2. Where virtio devices are bound to the Linux kernel driver in a guest
+       environment (i.e. interfaces are not bound to an in-guest DPDK driver),
+       the MTU of those logical network interfaces must also be increased to a
+       sufficiently large value. This avoids segmentation of Jumbo Frames
+       received in the guest. Note that 'MTU' refers to the length of the IP
+       packet only, and not that of the entire frame.
+
+       To calculate the exact MTU of a standard IPv4 frame, subtract the L2
+       header and CRC lengths (i.e. 18B) from the max supported frame size.
+       So, to set the MTU for a 9018B Jumbo Frame:
+
+       ```
+       ifconfig eth1 mtu 9000
+       ```
+
+## <a name="vsperf"></a> 11. Vsperf
 
 Vsperf project goal is to develop vSwitch test framework that can be used to
 validate the suitability of different vSwitch implementations in a Telco deployment
INSTALL.DPDK.md +0 -1
index 253d022..a810ac8 100644
@@ -590,7 +590,6 @@ can be found in [Vhost Walkthrough].
 
 ## <a name="ovslimits"></a> 6. Limitations
 
-  - Supports MTU size 1500, MTU setting for DPDK netdevs will be in future OVS release.
   - Currently DPDK ports does not use HW offload functionality.
   - Network Interface Firmware requirements:
     Each release of DPDK is validated against a specific firmware version for
NEWS +1 -0
index ce10982..53c816b 100644
@@ -69,6 +69,7 @@ Post-v2.5.0
      * Basic connection tracking for the userspace datapath (no ALG,
        fragmentation or NAT support yet)
      * Support for DPDK 16.07
+     * Jumbo frame support
    - Increase number of registers to 16.
    - ovs-benchmark: This utility has been removed due to lack of use and
      bitrot.
lib/netdev-dpdk.c +141 -24

317 lines not on this page · raw message

Signature · 1 line
1.9.3
#7 lore raw
In reply to Mark Kavanagh

Please disregard this patchset - it was sent erroneously to the incorrect mailing list.

I've already removed the related patches from Patchwork.

Cheers,
Mark

Quoted 92 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Mark Kavanagh
Sent: Friday, August 5, 2016 3:30 PM
To: [email protected]; [email protected]
Cc: [email protected]
Subject: [dpdk-dev] [PATCH 1/7] ofproto: Consider datapath_type when looking for internal ports.

From: Daniele Di Proietto <[email protected]>

Interfaces with type "internal" end up having a netdev with type "tap" in the dpif-netdev datapath, so a strcmp will fail to match internal interfaces.

We can translate the types with ofproto_port_open_type() before calling strcmp to fix this.

This fixes a minor issue where internal interfaces are considered non-internal in the userspace datapath for the purpose of adjusting the MTU.

---
ofproto/ofproto.c | 16 +++++++++-------

1 file changed, 9 insertions(+), 7 deletions(-)
ofproto/ofproto.c +2 -1
index 8e59c69..088f91a 100644
@@ -220,7 +220,8 @@ static void learned_cookies_flush(struct ofproto *, struct ovs_list
 *dead_cookie
 /* 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 inline bool ofport_is_internal(const struct ofproto *,
+                                      const struct ofport *);
 
 static int update_port(struct ofproto *, const char *devname);

static int init_ports(struct ofproto *);

ofproto/ofproto.c +1 -1
@@ -2465,7 +2466,7 @@ static void
 ofport_remove(struct ofport *ofport)
 {
    struct ofproto *p = ofport->ofproto;
-    bool is_internal = ofport_is_internal(ofport);
+    bool is_internal = ofport_is_internal(p, ofport);
 
    connmgr_send_port_status(ofport->ofproto->connmgr, NULL, &ofport->pp,
                             OFPPR_DELETE);
@@ -2751,9 +2752,10 @@ init_ports(struct ofproto *p)
 }
 

static inline bool

ofproto/ofproto.c +1 -1
-ofport_is_internal(const struct ofport *port)
+ofport_is_internal(const struct ofproto *p, const struct ofport *port)

{

ofproto/ofproto.c +2 -1
-    return !strcmp(netdev_get_type(port->netdev), "internal");
+    return !strcmp(netdev_get_type(port->netdev),
+                   ofproto_port_open_type(p->type, "internal"));

}

/* Find the minimum MTU of all non-datapath devices attached to 'p'.

ofproto/ofproto.c +3 -4
@@ -2770,7 +2772,7 @@ find_min_mtu(struct ofproto *p)
 
        /* Skip any internal ports, since that's what we're trying to
         * set. */
-        if (ofport_is_internal(ofport)) {
+        if (ofport_is_internal(p, ofport)) {
            continue;
        }
 
@@ -2797,7 +2799,7 @@ update_mtu(struct ofproto *p, struct ofport *port)
        port->mtu = 0;
        return;
    }
-    if (ofport_is_internal(port)) {
+    if (ofport_is_internal(p, port)) {
        if (dev_mtu > p->min_mtu) {
           if (!netdev_set_mtu(port->netdev, p->min_mtu)) {
               dev_mtu = p->min_mtu;
@@ -2827,7 +2829,7 @@ update_mtu_ofproto(struct ofproto *p)
    HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
        struct netdev *netdev = ofport->netdev;
 
-        if (ofport_is_internal(ofport)) {
+        if (ofport_is_internal(p, ofport)) {
            if (!netdev_set_mtu(netdev, p->min_mtu)) {
                ofport->mtu = p->min_mtu;
            }
--

1.9.3