コード例 #1
0
ファイル: ethernet.c プロジェクト: nirmoy/wicked
/*
 * Get ethernet specific settings from the kernel
 */
void
__ni_system_ethernet_refresh(ni_netdev_t *dev)
{
	ni_ethernet_t *ethernet;
	ni_ethtool_t *ethtool;

	if (!ni_netdev_device_is_ready(dev) || !dev->link.ifindex)
		return;

	/* A permanent address is not strictly ethernet specific,
	 * we just don't query it along with ethtool options as
	 * most (virtual) devices provide all-zeroes hw-address.
	 *
	 * As infiniband does not permit to change hw-address,
	 * it never differs from the normal dev->link.hwaddr.
	 */
	ethernet = ni_ethernet_new();
	ethernet->permanent_address.type = dev->link.hwaddr.type;
	if ((ethtool = ni_netdev_get_ethtool(dev))) {
		ni_netdev_ref_t ref;

		ref.name = dev->name;
		ref.index = dev->link.ifindex;
		ni_ethtool_get_permanent_address(&ref, ethtool,
				&ethernet->permanent_address);
	}
	ni_netdev_set_ethernet(dev, ethernet);
}
コード例 #2
0
ファイル: ifdown.c プロジェクト: mijos/wicked
ni_bool_t
ni_ifdown_fire_nanny(ni_ifworker_array_t *array)
{
	unsigned int i;
	char *policy_name;

	/* Deleting all requested policies */
	for (i = 0; i < array->count; i++) {
		ni_ifworker_t *w = array->data[i];

		policy_name = ni_ifpolicy_name_from_ifname(w->name);
		if (!ni_ifdown_stop_policy(policy_name)) {
			/* We ignore errors for now */;
		}
		ni_string_free(&policy_name);
	}

	/* Disabling all requested devices */
	for (i = 0; i < array->count; i++) {
		ni_ifworker_t *w = array->data[i];
		ni_netdev_t *dev = w ? w->device : NULL;

		/* Ignore non-existing device */
		if (!dev || !ni_netdev_device_is_ready(dev)) {
			continue;
		}

		if (!ni_ifdown_stop_device(w->name)) {
			/* We ignore errors for now */;
		}
	}

	return TRUE;
}
コード例 #3
0
ファイル: ethtool.c プロジェクト: mtomaschewski/wicked
void
ni_system_ethtool_refresh(ni_netdev_t *dev)
{
	if (!ni_netdev_device_is_ready(dev) || !dev->link.ifindex)
		return;

	ni_ethtool_refresh(dev);
}
コード例 #4
0
ファイル: ethtool.c プロジェクト: mtomaschewski/wicked
int
ni_system_ethtool_setup(ni_netconfig_t *nc, ni_netdev_t *dev, const ni_netdev_t *cfg)
{
	if (!ni_netdev_device_is_ready(dev) || !dev->link.ifindex)
		return -1;

	if (!dev->ethtool && !ni_ethtool_refresh(dev))
		return -1;

	if (cfg && cfg->ethtool) {
		ni_ethtool_set_priv_flags(dev->name, dev->ethtool, cfg->ethtool->priv_flags);
		ni_ethtool_refresh(dev);
	}
	return 0;
}