summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/netdev-vport.c21
-rw-r--r--lib/netdev-vport.h2
-rw-r--r--ofproto/ofproto-dpif.c8
3 files changed, 22 insertions, 9 deletions
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index ac3da6345..287edae32 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -553,12 +553,23 @@ get_tunnel_config(const struct netdev *dev, struct smap *args)
/* Code specific to patch ports. */
-const char *
-netdev_vport_patch_peer(const struct netdev *netdev)
+/* If 'netdev' is a patch port, returns the name of its peer as a malloc()'d
+ * string that the caller must free.
+ *
+ * If 'netdev' is not a patch port, returns NULL. */
+char *
+netdev_vport_patch_peer(const struct netdev *netdev_)
{
- return (netdev_vport_is_patch(netdev)
- ? netdev_vport_cast(netdev)->peer
- : NULL);
+ char *peer = NULL;
+
+ if (netdev_vport_is_patch(netdev_)) {
+ struct netdev_vport *netdev = netdev_vport_cast(netdev_);
+ if (netdev->peer) {
+ peer = xstrdup(netdev->peer);
+ }
+ }
+
+ return peer;
}
void
diff --git a/lib/netdev-vport.h b/lib/netdev-vport.h
index 53949666e..dc490970c 100644
--- a/lib/netdev-vport.h
+++ b/lib/netdev-vport.h
@@ -31,7 +31,7 @@ void netdev_vport_patch_register(void);
bool netdev_vport_is_patch(const struct netdev *);
-const char *netdev_vport_patch_peer(const struct netdev *netdev);
+char *netdev_vport_patch_peer(const struct netdev *netdev);
void netdev_vport_inc_rx(const struct netdev *,
const struct dpif_flow_stats *);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 15826193f..13faad680 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -2905,7 +2905,7 @@ ofport_update_peer(struct ofport_dpif *ofport)
{
const struct ofproto_dpif *ofproto;
struct dpif_backer *backer;
- const char *peer_name;
+ char *peer_name;
if (!netdev_vport_is_patch(ofport->up.netdev)) {
return;
@@ -2927,7 +2927,7 @@ ofport_update_peer(struct ofport_dpif *ofport)
HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
struct ofport *peer_ofport;
struct ofport_dpif *peer;
- const char *peer_peer;
+ char *peer_peer;
if (ofproto->backer != backer) {
continue;
@@ -2945,9 +2945,11 @@ ofport_update_peer(struct ofport_dpif *ofport)
ofport->peer = peer;
ofport->peer->peer = ofport;
}
+ free(peer_peer);
- return;
+ break;
}
+ free(peer_name);
}
static void