@@ -964,30 +964,6 @@ get_tunnel_config(const struct netdev *dev, struct smap *args)
return 0;
}
-
-/* Code specific to patch ports. */
-
-/* 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_)
-{
- char *peer = NULL;
-
- if (netdev_vport_is_patch(netdev_)) {
- struct netdev_vport *netdev = netdev_vport_cast(netdev_);
-
- ovs_mutex_lock(&netdev->mutex);
- if (netdev->peer) {
- peer = xstrdup(netdev->peer);
- }
- ovs_mutex_unlock(&netdev->mutex);
- }
-
- return peer;
-}
void
netdev_vport_inc_rx(const struct netdev *netdev,
@@ -1067,6 +1043,21 @@ set_patch_config(struct netdev *dev_, const struct smap *args, char **errp)
return 0;
}
+static char *
+get_patch_peer_name(const struct netdev *netdev_)
+{
+ struct netdev_vport *netdev = netdev_vport_cast(netdev_);
+ char *peer = NULL;
+
+ ovs_mutex_lock(&netdev->mutex);
+ if (netdev->peer) {
+ peer = xstrdup(netdev->peer);
+ }
+ ovs_mutex_unlock(&netdev->mutex);
+
+ return peer;
+}
+
static int
netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats)
{
@@ -1241,6 +1232,7 @@ netdev_vport_patch_register(void)
.type = "patch",
.get_config = get_patch_config,
.set_config = set_patch_config,
+ .get_peer_name = get_patch_peer_name,
},
{{NULL, NULL, 0, 0}}
};
@@ -32,8 +32,6 @@ void netdev_vport_patch_register(void);
bool netdev_vport_is_patch(const struct netdev *);
-char *netdev_vport_patch_peer(const struct netdev *netdev);
-
void netdev_vport_inc_rx(const struct netdev *,
const struct dpif_flow_stats *);
void netdev_vport_inc_tx(const struct netdev *,
@@ -3526,7 +3526,7 @@ ofport_update_peer(struct ofport_dpif *ofport)
ofport->peer = NULL;
}
- peer_name = netdev_vport_patch_peer(ofport->up.netdev);
+ peer_name = netdev_get_peer_name(ofport->up.netdev);
if (!peer_name) {
return;
}
@@ -3547,7 +3547,7 @@ ofport_update_peer(struct ofport_dpif *ofport)
}
peer = ofport_dpif_cast(peer_ofport);
- peer_peer = netdev_vport_patch_peer(peer->up.netdev);
+ peer_peer = netdev_get_peer_name(peer->up.netdev);
if (peer_peer && !strcmp(netdev_get_name(ofport->up.netdev),
peer_peer)) {
ofport->peer = peer;
@@ -3777,7 +3777,7 @@ vport_get_status(const struct ofport *ofport_, char **errp)
return 0;
}
- peer_name = netdev_vport_patch_peer(ofport->up.netdev);
+ peer_name = netdev_get_peer_name(ofport->up.netdev);
if (!peer_name) {
return 0;
}