示例#1
0
void iplink_usage(void)
{
	if (iplink_have_newlink()) {
		fprintf(stderr, "Usage: ip link add [link DEV] [ name ] NAME\n");
		fprintf(stderr, "                   [ txqueuelen PACKETS ]\n");
		fprintf(stderr, "                   [ address LLADDR ]\n");
		fprintf(stderr, "                   [ broadcast LLADDR ]\n");
		fprintf(stderr, "                   [ mtu MTU ] [index IDX ]\n");
		fprintf(stderr, "                   [ numtxqueues QUEUE_COUNT ]\n");
		fprintf(stderr, "                   [ numrxqueues QUEUE_COUNT ]\n");
		fprintf(stderr, "                   type TYPE [ ARGS ]\n");
		fprintf(stderr, "       ip link delete DEV type TYPE [ ARGS ]\n");
		fprintf(stderr, "\n");
		fprintf(stderr, "       ip link set { dev DEVICE | group DEVGROUP } [ { up | down } ]\n");
	} else
		fprintf(stderr, "Usage: ip link set DEVICE [ { up | down } ]\n");

	fprintf(stderr, "	                  [ arp { on | off } ]\n");
	fprintf(stderr, "	                  [ dynamic { on | off } ]\n");
	fprintf(stderr, "	                  [ multicast { on | off } ]\n");
	fprintf(stderr, "	                  [ allmulticast { on | off } ]\n");
	fprintf(stderr, "	                  [ promisc { on | off } ]\n");
	fprintf(stderr, "	                  [ trailers { on | off } ]\n");
	fprintf(stderr, "	                  [ txqueuelen PACKETS ]\n");
	fprintf(stderr, "	                  [ name NEWNAME ]\n");
	fprintf(stderr, "	                  [ address LLADDR ]\n");
	fprintf(stderr, "	                  [ broadcast LLADDR ]\n");
	fprintf(stderr, "	                  [ mtu MTU ]\n");
	fprintf(stderr, "	                  [ netns PID ]\n");
	fprintf(stderr, "	                  [ netns NAME ]\n");
	fprintf(stderr, "			  [ alias NAME ]\n");
	fprintf(stderr, "	                  [ vf NUM [ mac LLADDR ]\n");
	fprintf(stderr, "				   [ vlan VLANID [ qos VLAN-QOS ] ]\n");

	fprintf(stderr, "				   [ rate TXRATE ] ] \n");

	fprintf(stderr, "				   [ spoofchk { on | off} ] ] \n");
	fprintf(stderr, "				   [ state { auto | enable | disable} ] ]\n");
	fprintf(stderr, "			  [ master DEVICE ]\n");
	fprintf(stderr, "			  [ nomaster ]\n");
	fprintf(stderr, "       ip link show [ DEVICE | group GROUP ] [up]\n");

	if (iplink_have_newlink()) {
		fprintf(stderr, "\n");
		fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n");
		fprintf(stderr, "          bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan |\n");
		fprintf(stderr, "          gre | gretap | ip6gre | ip6gretap | vti | nlmon }\n");
	}
	exit(-1);
}
示例#2
0
int
iface_gre_del(const char *gre_iface)
{
    struct softgred_config *cfg = softgred_config_ref();
    int ret;
    errno = 0;

    if ((ret=rtnl_open(&cfg->rth, 0)) < 0)
    {
        D_DEBUG1("Cannot open rtnetlink\n");
        return EXIT_FAILURE;
    }

    if(!iplink_have_newlink())
    {
        D_DEBUG1("iplink_have_newlink ret=%d strerror='%s'\n", ret, strerror(errno));
    }
    else
    {
        ret = iplink_modify(RTM_DELLINK, 0, gre_iface, NULL, NULL, NULL, NULL);
        if (ret != 0)
        {
            D_DEBUG1("iplink_modify(RTM_DELLINK) ret=%d strerror='%s'\n", ret, strerror(errno));
        }
    }

    rtnl_close(&cfg->rth);

    return 1;
}
示例#3
0
文件: iplink.c 项目: KHATEEBNSIT/AP
void iplink_usage(void)
{
	if (iplink_have_newlink()) {
		fprintf(stderr, "Usage: ip link add [link DEV] [ name ] NAME\n");
		fprintf(stderr, "                   [ txqueuelen PACKETS ]\n");
		fprintf(stderr, "                   [ address LLADDR ]\n");
		fprintf(stderr, "                   [ broadcast LLADDR ]\n");
		fprintf(stderr, "                   [ mtu MTU ]\n");
		fprintf(stderr, "                   [ numtxqueues QUEUE_COUNT ]\n");
		fprintf(stderr, "                   [ numrxqueues QUEUE_COUNT ]\n");
		fprintf(stderr, "                   type TYPE [ ARGS ]\n");
		fprintf(stderr, "       ip link delete DEV type TYPE [ ARGS ]\n");
		fprintf(stderr, "\n");
		fprintf(stderr, "       ip link set { dev DEVICE | group DEVGROUP } [ { up | down } ]\n");
	} else
		fprintf(stderr, "Usage: ip link set DEVICE [ { up | down } ]\n");

	fprintf(stderr, "	                  [ arp { on | off } ]\n");
	fprintf(stderr, "	                  [ dynamic { on | off } ]\n");
	fprintf(stderr, "	                  [ multicast { on | off } ]\n");
	fprintf(stderr, "	                  [ allmulticast { on | off } ]\n");
	fprintf(stderr, "	                  [ promisc { on | off } ]\n");
	fprintf(stderr, "	                  [ trailers { on | off } ]\n");
	fprintf(stderr, "	                  [ txqueuelen PACKETS ]\n");
	fprintf(stderr, "	                  [ name NEWNAME ]\n");
	fprintf(stderr, "	                  [ address LLADDR ]\n");
	fprintf(stderr, "	                  [ broadcast LLADDR ]\n");
	fprintf(stderr, "	                  [ mtu MTU ]\n");
	fprintf(stderr, "	                  [ netns PID ]\n");
	fprintf(stderr, "	                  [ netns NAME ]\n");
	fprintf(stderr, "			  [ alias NAME ]\n");
	fprintf(stderr, "	                  [ vf NUM [ mac LLADDR ]\n");
	fprintf(stderr, "				   [ vlan VLANID [ qos VLAN-QOS ] ]\n");

	fprintf(stderr, "				   [ rate TXRATE ] ] \n");

	fprintf(stderr, "				   [ spoofchk { on | off} ] ] \n");
	fprintf(stderr, "			  [ master DEVICE ]\n");
	fprintf(stderr, "			  [ nomaster ]\n");
	fprintf(stderr, "       ip link show [ DEVICE | group GROUP ]\n");

	if (iplink_have_newlink()) {
		fprintf(stderr, "\n");
		fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | can | bridge }\n");
	}
	exit(-1);
}
void iplink_usage(void)
{
	if (iplink_have_newlink()) {
		fprintf(stderr, "Usage: ip link add link DEV [ name ] NAME\n");
		fprintf(stderr, "                   [ txqueuelen PACKETS ]\n");
		fprintf(stderr, "                   [ address LLADDR ]\n");
		fprintf(stderr, "                   [ broadcast LLADDR ]\n");
		fprintf(stderr, "                   [ mtu MTU ]\n");
		fprintf(stderr, "                   type TYPE [ ARGS ]\n");
		fprintf(stderr, "       ip link delete DEV type TYPE [ ARGS ]\n");
		fprintf(stderr, "\n");
		fprintf(stderr, "       ip link set DEVICE [ { up | down } ]\n");
	} else
		fprintf(stderr, "Usage: ip link set DEVICE [ { up | down } ]\n");

	fprintf(stderr, "	                  [ arp { on | off } ]\n");
	fprintf(stderr, "	                  [ dynamic { on | off } ]\n");
	fprintf(stderr, "	                  [ multicast { on | off } ]\n");
	fprintf(stderr, "	                  [ allmulticast { on | off } ]\n");
	fprintf(stderr, "	                  [ multipath { on | off | backup | handover} ]\n");
	fprintf(stderr, "	                  [ promisc { on | off } ]\n");
	fprintf(stderr, "	                  [ trailers { on | off } ]\n");
	fprintf(stderr, "	                  [ txqueuelen PACKETS ]\n");
	fprintf(stderr, "	                  [ name NEWNAME ]\n");
	fprintf(stderr, "	                  [ address LLADDR ]\n");
	fprintf(stderr, "	                  [ broadcast LLADDR ]\n");
	fprintf(stderr, "	                  [ mtu MTU ]\n");
	fprintf(stderr, "	                  [ netns PID ]\n");
	fprintf(stderr, "			  [ alias NAME ]\n");
	fprintf(stderr, "	                  [ vf NUM [ mac LLADDR ]\n");
	fprintf(stderr, "				   [ vlan VLANID [ qos VLAN-QOS ] ]\n");
	fprintf(stderr, "				   [ rate TXRATE ] ] \n");
	fprintf(stderr, "       ip link show [ DEVICE ]\n");

	if (iplink_have_newlink()) {
		fprintf(stderr, "\n");
		fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | can }\n");
	}
	exit(-1);
}
示例#5
0
int
iface_gre_add(const char *gre_iface,
              const char *type,
              const char *dev_to_link,
              const struct in_addr *in_local,
              const struct in_addr *in_remote)
{
    struct softgred_config *cfg = softgred_config_ref();
    int ret = true;
    char *ip_local = strdupa(inet_ntoa(*in_local));
    char *ip_remote = strdupa(inet_ntoa(*in_remote));

    D_DEBUG1("Creating gre-interface '%s' { .local='%s', .remote='%s' }\n", 
            gre_iface, ip_local, ip_remote
    );

    if ((ret=rtnl_open(&cfg->rth, 0)) < 0)
    {
        D_DEBUG1("rtnl_open ret=%d strerror='%s'\n", ret, strerror(errno));
        return EXIT_FAILURE;
    }

    if (!iplink_have_newlink())
    {
        D_DEBUG1("iplink_have_newlink ret=%d strerror='%s'\n", ret, strerror(errno));
    }
    else
    {
        ret = iplink_modify(RTM_NEWLINK,
                            NLM_F_CREATE | NLM_F_EXCL,
                            gre_iface,
                            dev_to_link,
                            type,
                            in_local,
                            in_remote);
        if (ret != 0)
            D_DEBUG2("iplink_modify(RTM_NEWLINK) ret=%d strerror='%s'\n", ret, strerror(errno));
    }

    rtnl_close(&cfg->rth);

    return 1;
}
示例#6
0
int do_iplink(int argc, char **argv)
{
	if (argc > 0) {
		if (iplink_have_newlink()) {
			if (matches(*argv, "add") == 0)
				return iplink_modify(RTM_NEWLINK,
						     NLM_F_CREATE|NLM_F_EXCL,
						     argc-1, argv+1);
			if (matches(*argv, "set") == 0 ||
			    matches(*argv, "change") == 0)
				return iplink_modify(RTM_NEWLINK, 0,
						     argc-1, argv+1);
			if (matches(*argv, "replace") == 0)
				return iplink_modify(RTM_NEWLINK,
						     NLM_F_CREATE|NLM_F_REPLACE,
						     argc-1, argv+1);
			if (matches(*argv, "delete") == 0)
				return iplink_modify(RTM_DELLINK, 0,
						     argc-1, argv+1);
		} else {
#if IPLINK_IOCTL_COMPAT
			if (matches(*argv, "set") == 0)
				return do_set(argc-1, argv+1);
#endif
		}
		if (matches(*argv, "show") == 0 ||
		    matches(*argv, "lst") == 0 ||
		    matches(*argv, "list") == 0)
			return ipaddr_list_link(argc-1, argv+1);
		if (matches(*argv, "help") == 0)
			usage();
	} else
		return ipaddr_list_link(0, NULL);

	fprintf(stderr, "Command \"%s\" is unknown, try \"ip link help\".\n", *argv);
	exit(-1);
}
示例#7
0
void iplink_usage(void)
{
	if (iplink_have_newlink()) {
		fprintf(stderr,
			"Usage: ip link add [link DEV] [ name ] NAME\n"
			"                   [ txqueuelen PACKETS ]\n"
			"                   [ address LLADDR ]\n"
			"                   [ broadcast LLADDR ]\n"
			"                   [ mtu MTU ] [index IDX ]\n"
			"                   [ numtxqueues QUEUE_COUNT ]\n"
			"                   [ numrxqueues QUEUE_COUNT ]\n"
			"                   type TYPE [ ARGS ]\n"
			"\n"
			"       ip link delete { DEVICE | dev DEVICE | group DEVGROUP } type TYPE [ ARGS ]\n"
			"\n"
			"       ip link set { DEVICE | dev DEVICE | group DEVGROUP }\n"
			"	                  [ { up | down } ]\n"
			"	                  [ type TYPE ARGS ]\n");
	} else
		fprintf(stderr,
			"Usage: ip link set DEVICE [ { up | down } ]\n");

	fprintf(stderr,
		"	                  [ arp { on | off } ]\n"
		"	                  [ dynamic { on | off } ]\n"
		"	                  [ multicast { on | off } ]\n"
		"	                  [ allmulticast { on | off } ]\n"
		"	                  [ promisc { on | off } ]\n"
		"	                  [ trailers { on | off } ]\n"
		"	                  [ carrier { on | off } ]\n"
		"	                  [ txqueuelen PACKETS ]\n"
		"	                  [ name NEWNAME ]\n"
		"	                  [ address LLADDR ]\n"
		"	                  [ broadcast LLADDR ]\n"
		"	                  [ mtu MTU ]\n"
		"	                  [ netns { PID | NAME } ]\n"
		"	                  [ link-netnsid ID ]\n"
		"			  [ alias NAME ]\n"
		"	                  [ vf NUM [ mac LLADDR ]\n"
		"				   [ vlan VLANID [ qos VLAN-QOS ] [ proto VLAN-PROTO ] ]\n"
		"				   [ rate TXRATE ]\n"
		"				   [ max_tx_rate TXRATE ]\n"
		"				   [ min_tx_rate TXRATE ]\n"
		"				   [ spoofchk { on | off} ]\n"
		"				   [ query_rss { on | off} ]\n"
		"				   [ state { auto | enable | disable} ] ]\n"
		"				   [ trust { on | off} ] ]\n"
		"				   [ node_guid { eui64 } ]\n"
		"				   [ port_guid { eui64 } ]\n"
		"			  [ xdp { off |\n"
		"				  object FILE [ section NAME ] [ verbose ] |\n"
		"				  pinned FILE } ]\n"
		"			  [ master DEVICE ][ vrf NAME ]\n"
		"			  [ nomaster ]\n"
		"			  [ addrgenmode { eui64 | none | stable_secret | random } ]\n"
		"	                  [ protodown { on | off } ]\n"
		"\n"
		"       ip link show [ DEVICE | group GROUP ] [up] [master DEV] [vrf NAME] [type TYPE]\n");

	fprintf(stderr, "\n       ip link xstats type TYPE [ ARGS ]\n");
	fprintf(stderr, "\n       ip link afstats [ dev DEVICE ]\n");

	if (iplink_have_newlink()) {
		fprintf(stderr,
			"\n"
			"       ip link help [ TYPE ]\n"
			"\n"
			"TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n"
			"          bridge | bond | team | ipoib | ip6tnl | ipip | sit | vxlan |\n"
			"          gre | gretap | ip6gre | ip6gretap | vti | nlmon | team_slave |\n"
			"          bond_slave | ipvlan | geneve | bridge_slave | vrf | macsec }\n");
	}
	exit(-1);
}