}
const char *
-netdev_vport_get_dpif_port(const struct netdev *netdev)
+netdev_vport_get_dpif_port(const struct netdev *netdev,
+ char namebuf[], size_t bufsize)
{
- const char *dpif_port;
-
if (netdev_vport_needs_dst_port(netdev)) {
const struct netdev_vport *vport = netdev_vport_cast(netdev);
const char *type = netdev_get_type(netdev);
- static char dpif_port_combined[IFNAMSIZ];
/*
* Note: IFNAMSIZ is 16 bytes long. The maximum length of a VXLAN
* assert here on the size of strlen(type) in case that changes
* in the future.
*/
+ BUILD_ASSERT(NETDEV_VPORT_NAME_BUFSIZE >= IFNAMSIZ);
ovs_assert(strlen(type) + 10 < IFNAMSIZ);
- snprintf(dpif_port_combined, IFNAMSIZ, "%s_sys_%d", type,
+ snprintf(namebuf, bufsize, "%s_sys_%d", type,
ntohs(vport->tnl_cfg.dst_port));
- return dpif_port_combined;
+ return namebuf;
} else {
const struct netdev_class *class = netdev_get_class(netdev);
- dpif_port = netdev_vport_class_get_dpif_port(class);
+ const char *dpif_port = netdev_vport_class_get_dpif_port(class);
+ return dpif_port ? dpif_port : netdev_get_name(netdev);
}
+}
+
+char *
+netdev_vport_get_dpif_port_strdup(const struct netdev *netdev)
+{
+ char namebuf[NETDEV_VPORT_NAME_BUFSIZE];
- return dpif_port ? dpif_port : netdev_get_name(netdev);
+ return xstrdup(netdev_vport_get_dpif_port(netdev, namebuf,
+ sizeof namebuf));
}
static int
static int
tunnel_get_status(const struct netdev *netdev, struct smap *smap)
{
- static char iface[IFNAMSIZ];
+ char iface[IFNAMSIZ];
ovs_be32 route;
route = netdev_vport_cast(netdev)->tnl_cfg.ip_dst;
}
if (tnl_cfg.ipsec) {
+ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static pid_t pid = 0;
+
+ pthread_mutex_lock(&mutex);
if (pid <= 0) {
char *file_name = xasprintf("%s/%s", ovs_rundir(),
"ovs-monitor-ipsec.pid");
pid = read_pidfile(file_name);
free(file_name);
}
+ pthread_mutex_unlock(&mutex);
if (pid < 0) {
VLOG_ERR("%s: IPsec requires the ovs-monitor-ipsec daemon",
free(dev->peer);
dev->peer = xstrdup(peer);
-
+ netdev_vport_poll_notify(dev);
return 0;
}