Skip to content

Commit

Permalink
ovs: use generic ovs type until we can query ovs
Browse files Browse the repository at this point in the history
Query if ovs device is a bridge using ovs-vsctl br-exists
first, then query the further bridge details (bsc#982231).
  • Loading branch information
mtomaschewski committed Jul 19, 2016
1 parent 9516121 commit c1ab125
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
1 change: 1 addition & 0 deletions include/wicked/constants.h
Expand Up @@ -73,6 +73,7 @@ typedef enum ni_iftype {
NI_IFTYPE_TEAM,
NI_IFTYPE_OVS_SYSTEM,
NI_IFTYPE_OVS_BRIDGE,
NI_IFTYPE_OVS_UNSPEC,

__NI_IFTYPE_MAX
} ni_iftype_t;
Expand Down
46 changes: 33 additions & 13 deletions src/iflist.c
Expand Up @@ -1047,7 +1047,30 @@ __ni_netdev_translate_ifflags(unsigned int ifflags, unsigned int prev)
}

static void
__ni_process_ifinfomsg_linktype(ni_linkinfo_t *link, const char *ifname)
__ni_process_ifinfomsg_ovs_type(ni_iftype_t *type, const char *ifname, ni_netconfig_t *nc)
{
static const char *ovs_system = NULL;

/* special, reserved openvswitch datapath device name */
if (ovs_system == NULL)
ovs_system = ni_linktype_type_to_name(NI_IFTYPE_OVS_SYSTEM);

if (ni_string_eq(ifname, ovs_system))
*type = NI_IFTYPE_OVS_SYSTEM;

/* we don't know whether this is really a bridge or some
* other ovs device until we were able to query ovs about.
* Until then, it is an unspecified ovs device.
*/
if (ni_netconfig_discover_filtered(nc, NI_NETCONFIG_DISCOVER_LINK_EXTERN))
return;

if (ni_ovs_vsctl_bridge_exists(ifname) == 0)
*type = NI_IFTYPE_OVS_BRIDGE;
}

static void
__ni_process_ifinfomsg_linktype(ni_linkinfo_t *link, const char *ifname, ni_netconfig_t *nc)
{
ni_iftype_t tmp_link_type = NI_IFTYPE_UNKNOWN;
struct ethtool_drvinfo drv_info;
Expand All @@ -1069,6 +1092,10 @@ __ni_process_ifinfomsg_linktype(ni_linkinfo_t *link, const char *ifname)
tmp_link_type = NI_IFTYPE_TAP;
break;

case NI_IFTYPE_OVS_UNSPEC:
__ni_process_ifinfomsg_ovs_type(&tmp_link_type, ifname, nc);
break;

case NI_IFTYPE_UNKNOWN:
switch (link->hwaddr.type) {
case ARPHRD_LOOPBACK:
Expand Down Expand Up @@ -1102,15 +1129,8 @@ __ni_process_ifinfomsg_linktype(ni_linkinfo_t *link, const char *ifname)
} else if (!strcmp(driver, "802.1Q VLAN Support")) {
tmp_link_type = NI_IFTYPE_VLAN;
} else if (!strcmp(driver, "openvswitch")) {
static const char *ovs_system = NULL;

/* special openvswitch datapath (master) device */
if (ovs_system == NULL)
ovs_system = ni_linktype_type_to_name(NI_IFTYPE_OVS_SYSTEM);
if (ni_string_eq(ifname, ovs_system))
tmp_link_type = NI_IFTYPE_OVS_SYSTEM;
else
tmp_link_type = NI_IFTYPE_OVS_BRIDGE;
tmp_link_type = NI_IFTYPE_OVS_UNSPEC;
__ni_process_ifinfomsg_ovs_type(&tmp_link_type, ifname, nc);
}
}
break;
Expand Down Expand Up @@ -1181,8 +1201,8 @@ __ni_process_ifinfomsg_linktype(ni_linkinfo_t *link, const char *ifname)
link->type = tmp_link_type;
}
} else
if (link->type != tmp_link_type) {
/* We're trying to re-assign a link type, Disallow. */
if (link->type != tmp_link_type && tmp_link_type != NI_IFTYPE_OVS_UNSPEC) {
/* We're trying to re-assign a link type, complain. */
ni_error("%s: Ignoring attempt to reset existing interface link type from %s to %s",
ifname, ni_linktype_type_to_name(link->type),
ni_linktype_type_to_name(tmp_link_type));
Expand Down Expand Up @@ -1548,7 +1568,7 @@ __ni_process_ifinfomsg_linkinfo(ni_linkinfo_t *link, const char *ifname,
}

/* Attempt to determine linktype. */
__ni_process_ifinfomsg_linktype(link, ifname);
__ni_process_ifinfomsg_linktype(link, ifname, nc);

return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/names.c
Expand Up @@ -77,6 +77,7 @@ static const ni_intmap_t __linktype_names[] = {
{ "team", NI_IFTYPE_TEAM },
{ "ovs-system", NI_IFTYPE_OVS_SYSTEM },
{ "ovs-bridge", NI_IFTYPE_OVS_BRIDGE },
{ "ovs", NI_IFTYPE_OVS_UNSPEC },

{ NULL }
};
Expand Down Expand Up @@ -114,6 +115,7 @@ static const ni_intmap_t __linkinfo_kind_names[] = {
{ "sit", NI_IFTYPE_SIT },
{ "ipip", NI_IFTYPE_IPIP },
{ "gre", NI_IFTYPE_GRE },
{ "openvswitch", NI_IFTYPE_OVS_UNSPEC }, /* new in 4.4 kernels */

{ NULL }
};
Expand Down

0 comments on commit c1ab125

Please sign in to comment.