char *veth1, *veth2;
char veth1buf[IFNAMSIZ], veth2buf[IFNAMSIZ];
- if (netdev->priv.veth_attr.pair[0] != '\0') {
+ if (!is_empty_string(netdev->priv.veth_attr.pair)) {
veth1 = netdev->priv.veth_attr.pair;
if (handler->conf->reboot)
lxc_netdev_delete_by_name(veth1);
if (netdev->mtu) {
if (lxc_safe_uint(netdev->mtu, &mtu))
return log_error_errno(-1, errno, "Failed to parse mtu");
- } else if (netdev->link[0] != '\0') {
+ } else if (!is_empty_string(netdev->link)) {
int ifindex_mtu;
ifindex_mtu = if_nametoindex(netdev->link);
}
}
- if (netdev->link[0] != '\0' && netdev->priv.veth_attr.mode == VETH_MODE_BRIDGE) {
+ if (!is_empty_string(netdev->link) && netdev->priv.veth_attr.mode == VETH_MODE_BRIDGE) {
err = lxc_bridge_attach(netdev->link, veth1);
if (err) {
errno = -err;
char peer[IFNAMSIZ];
int err;
- if (netdev->link[0] == '\0') {
+ if (is_empty_string(netdev->link)) {
ERROR("No link for macvlan network device specified");
return -1;
}
char peer[IFNAMSIZ];
int err;
- if (netdev->link[0] == '\0') {
+ if (is_empty_string(netdev->link)) {
ERROR("No link for ipvlan network device specified");
return -1;
}
int err;
static uint16_t vlan_cntr = 0;
- if (netdev->link[0] == '\0') {
+ if (is_empty_string(netdev->link)) {
ERROR("No link for vlan network device specified");
return -1;
}
{
int err, mtu_orig = 0;
- if (netdev->link[0] == '\0') {
+ if (is_empty_string(netdev->link)) {
ERROR("No link for physical interface specified");
return -1;
}
if (!netdev->downscript)
return 0;
- if (netdev->priv.veth_attr.pair[0] != '\0')
+ if (!is_empty_string(netdev->priv.veth_attr.pair))
argv[2] = netdev->priv.veth_attr.pair;
else
argv[2] = netdev->priv.veth_attr.veth1;
return -1;
}
- if (netdev->link[0] == '\0') {
+ if (is_empty_string(netdev->link)) {
ERROR("Automatic gateway detection needs a link interface");
return -1;
}
_exit(EXIT_FAILURE);
}
- if (netdev->link[0] != '\0')
+ if (!is_empty_string(netdev->link))
retlen = strlcpy(netdev_link, netdev->link, IFNAMSIZ);
else
retlen = strlcpy(netdev_link, "none", IFNAMSIZ);
_exit(EXIT_FAILURE);
}
- if (netdev->priv.veth_attr.pair[0] != '\0')
+ if (!is_empty_string(netdev->priv.veth_attr.pair))
hostveth = netdev->priv.veth_attr.pair;
else
hostveth = netdev->priv.veth_attr.veth1;
- if (hostveth[0] == '\0') {
+ if (is_empty_string(hostveth)) {
SYSERROR("Host side veth device name is missing");
_exit(EXIT_FAILURE);
}
- if (netdev->link[0] == '\0') {
- SYSERROR("Network link for network device \"%s\" is "
- "missing", netdev->priv.veth_attr.veth1);
+ if (is_empty_string(netdev->link)) {
+ SYSERROR("Network link for network device \"%s\" is missing", netdev->priv.veth_attr.veth1);
_exit(EXIT_FAILURE);
}
close(pipefd[0]);
if (ret != 0 || bytes < 0) {
ERROR("lxc-user-nic failed to delete requested network: %s",
- buffer[0] != '\0' ? buffer : "(null)");
+ !is_empty_string(buffer) ? buffer : "(null)");
return -1;
}
if (netdev->type != LXC_NET_VETH)
goto clear_ifindices;
- if (netdev->link[0] == '\0' || !is_ovs_bridge(netdev->link))
+ if (is_empty_string(netdev->link) || !is_ovs_bridge(netdev->link))
goto clear_ifindices;
- if (netdev->priv.veth_attr.pair[0] != '\0')
+ if (!is_empty_string(netdev->priv.veth_attr.pair))
hostveth = netdev->priv.veth_attr.pair;
else
hostveth = netdev->priv.veth_attr.veth1;
- if (hostveth[0] == '\0')
+ if (is_empty_string(hostveth))
goto clear_ifindices;
ret = lxc_delete_network_unpriv_exec(handler->lxcpath,
}
/* If link is supplied remove the IP neigh proxy entry for this IP on the device. */
- if (link[0] != '\0') {
+ if (!is_empty_string(link)) {
link_ifindex = if_nametoindex(link);
if (link_ifindex == 0) {
ERROR("Failed to retrieve ifindex for \"%s\" l2proxy cleanup", link);
}
/* If link is supplied remove the IP neigh proxy entry for this IP on the device. */
- if (link[0] != '\0') {
+ if (!is_empty_string(link)) {
link_ifindex = if_nametoindex(link);
if (link_ifindex == 0) {
ERROR("Failed to retrieve ifindex for \"%s\" l2proxy cleanup", link);
}
/* Setup l2proxy entries if enabled and used with a link property */
- if (netdev->l2proxy && netdev->link[0] != '\0') {
+ if (netdev->l2proxy && !is_empty_string(netdev->link)) {
if (lxc_setup_l2proxy(netdev)) {
ERROR("Failed to setup l2proxy");
return -1;
netdev->ifindex = if_nametoindex(netdev->name);
/* Delete l2proxy entries if enabled and used with a link property */
- if (netdev->l2proxy && netdev->link[0] != '\0') {
+ if (netdev->l2proxy && !is_empty_string(netdev->link)) {
if (lxc_delete_l2proxy(netdev))
WARN("Failed to delete all l2proxy config");
/* Don't return, let the network be cleaned up as normal. */
/* Explicitly delete host veth device to prevent lingering
* devices. We had issues in LXD around this.
*/
- if (netdev->priv.veth_attr.pair[0] != '\0')
+ if (!is_empty_string(netdev->priv.veth_attr.pair))
hostveth = netdev->priv.veth_attr.pair;
else
hostveth = netdev->priv.veth_attr.veth1;
- if (hostveth[0] == '\0')
+ if (is_empty_string(hostveth))
goto clear_ifindices;
if (is_empty_string(netdev->link) || !is_ovs_bridge(netdev->link)) {