]>
git.proxmox.com Git - mirror_iproute2.git/blob - ip/link_veth.c
2 * link_veth.c veth driver module
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Pavel Emelianov <xemul@openvz.org>
15 #include <linux/veth.h>
18 #include "ip_common.h"
20 static void print_usage(FILE *f
)
22 printf("Usage: ip link <options> type veth [peer <options>]\n"
23 "To get <options> type 'ip link add help'\n");
26 static void usage(void)
31 static int veth_parse_opt(struct link_util
*lu
, int argc
, char **argv
,
42 struct ifinfomsg
*ifm
, *peer_ifm
;
43 unsigned int ifi_flags
, ifi_change
;
45 if (strcmp(argv
[0], "peer") != 0) {
50 ifm
= NLMSG_DATA(hdr
);
51 ifi_flags
= ifm
->ifi_flags
;
52 ifi_change
= ifm
->ifi_change
;
56 data
= NLMSG_TAIL(hdr
);
57 addattr_l(hdr
, 1024, VETH_INFO_PEER
, NULL
, 0);
59 hdr
->nlmsg_len
+= sizeof(struct ifinfomsg
);
61 err
= iplink_parse(argc
- 1, argv
+ 1, (struct iplink_req
*)hdr
,
62 &name
, &type
, &link
, &dev
, &group
, &index
);
67 len
= strlen(name
) + 1;
69 invarg("\"name\" too long\n", *argv
);
70 addattr_l(hdr
, 1024, IFLA_IFNAME
, name
, len
);
73 peer_ifm
= RTA_DATA(data
);
74 peer_ifm
->ifi_index
= index
;
75 peer_ifm
->ifi_flags
= ifm
->ifi_flags
;
76 peer_ifm
->ifi_change
= ifm
->ifi_change
;
77 ifm
->ifi_flags
= ifi_flags
;
78 ifm
->ifi_change
= ifi_change
;
81 addattr32(hdr
, 1024, IFLA_GROUP
, group
);
83 data
->rta_len
= (void *)NLMSG_TAIL(hdr
) - (void *)data
;
84 return argc
- 1 - err
;
87 static void veth_print_help(struct link_util
*lu
, int argc
, char **argv
,
93 struct link_util veth_link_util
= {
95 .parse_opt
= veth_parse_opt
,
96 .print_help
= veth_print_help
,