]>
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
,
37 struct ifinfomsg
*ifm
, *peer_ifm
;
38 unsigned int ifi_flags
, ifi_change
, ifi_index
;
40 if (strcmp(argv
[0], "peer") != 0) {
46 ifi_flags
= ifm
->ifi_flags
;
47 ifi_change
= ifm
->ifi_change
;
48 ifi_index
= ifm
->ifi_index
;
53 data
= addattr_nest(n
, 1024, VETH_INFO_PEER
);
55 n
->nlmsg_len
+= sizeof(struct ifinfomsg
);
57 err
= iplink_parse(argc
- 1, argv
+ 1, (struct iplink_req
*)n
, &type
);
62 duparg("type", argv
[err
]);
64 peer_ifm
= RTA_DATA(data
);
65 peer_ifm
->ifi_index
= ifm
->ifi_index
;
66 peer_ifm
->ifi_flags
= ifm
->ifi_flags
;
67 peer_ifm
->ifi_change
= ifm
->ifi_change
;
68 ifm
->ifi_flags
= ifi_flags
;
69 ifm
->ifi_change
= ifi_change
;
70 ifm
->ifi_index
= ifi_index
;
72 addattr_nest_end(n
, data
);
73 return argc
- 1 - err
;
76 static void veth_print_help(struct link_util
*lu
, int argc
, char **argv
,
82 struct link_util veth_link_util
= {
84 .parse_opt
= veth_parse_opt
,
85 .print_help
= veth_print_help
,