Commit 9a6422c2 authored by Stephen Hemminger's avatar Stephen Hemminger

Merge branch 'master' into net-next

parents e4d456f0 e3c27c2d
...@@ -19,7 +19,7 @@ static inline void *dlopen(const char *file, int flag) ...@@ -19,7 +19,7 @@ static inline void *dlopen(const char *file, int flag)
return NULL; return NULL;
} }
extern void *_dlsym(const char *sym); void *_dlsym(const char *sym);
static inline void *dlsym(void *handle, const char *sym) static inline void *dlsym(void *handle, const char *sym)
{ {
if (handle != _FAKE_DLFCN_HDL) if (handle != _FAKE_DLFCN_HDL)
......
...@@ -26,20 +26,20 @@ struct rtnl_handle ...@@ -26,20 +26,20 @@ struct rtnl_handle
extern int rcvbuf; extern int rcvbuf;
extern int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
extern int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,
int protocol) int protocol)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
extern void rtnl_close(struct rtnl_handle *rth); void rtnl_close(struct rtnl_handle *rth);
extern int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type) int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
extern int rtnl_wilddump_req_filter(struct rtnl_handle *rth, int fam, int type, int rtnl_wilddump_req_filter(struct rtnl_handle *rth, int fam, int type,
__u32 filt_mask) __u32 filt_mask)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req,
int len) int len)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
...@@ -60,40 +60,43 @@ struct rtnl_dump_filter_arg ...@@ -60,40 +60,43 @@ struct rtnl_dump_filter_arg
void *arg1; void *arg1;
}; };
extern int rtnl_dump_filter_l(struct rtnl_handle *rth, int rtnl_dump_filter_l(struct rtnl_handle *rth,
const struct rtnl_dump_filter_arg *arg); const struct rtnl_dump_filter_arg *arg);
extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter, int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter, void *arg);
void *arg); int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, struct nlmsghdr *answer, size_t len)
struct nlmsghdr *answer, size_t len)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
extern int rtnl_send(struct rtnl_handle *rth, const void *buf, int) int rtnl_send(struct rtnl_handle *rth, const void *buf, int)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
extern int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int) int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
extern int addattr(struct nlmsghdr *n, int maxlen, int type); int addattr(struct nlmsghdr *n, int maxlen, int type);
extern int addattr8(struct nlmsghdr *n, int maxlen, int type, __u8 data); int addattr8(struct nlmsghdr *n, int maxlen, int type, __u8 data);
extern int addattr16(struct nlmsghdr *n, int maxlen, int type, __u16 data); int addattr16(struct nlmsghdr *n, int maxlen, int type, __u16 data);
extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data); int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data);
extern int addattr64(struct nlmsghdr *n, int maxlen, int type, __u64 data); int addattr64(struct nlmsghdr *n, int maxlen, int type, __u64 data);
extern int addattrstrz(struct nlmsghdr *n, int maxlen, int type, const char *data); int addattrstrz(struct nlmsghdr *n, int maxlen, int type, const char *data);
extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen); int addattr_l(struct nlmsghdr *n, int maxlen, int type,
extern int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len); const void *data, int alen);
extern struct rtattr *addattr_nest(struct nlmsghdr *n, int maxlen, int type); int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len);
extern int addattr_nest_end(struct nlmsghdr *n, struct rtattr *nest); struct rtattr *addattr_nest(struct nlmsghdr *n, int maxlen, int type);
extern struct rtattr *addattr_nest_compat(struct nlmsghdr *n, int maxlen, int type, const void *data, int len); int addattr_nest_end(struct nlmsghdr *n, struct rtattr *nest);
extern int addattr_nest_compat_end(struct nlmsghdr *n, struct rtattr *nest); struct rtattr *addattr_nest_compat(struct nlmsghdr *n, int maxlen, int type,
extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data); const void *data, int len);
extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, const void *data, int alen); int addattr_nest_compat_end(struct nlmsghdr *n, struct rtattr *nest);
int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data);
extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len); int rta_addattr_l(struct rtattr *rta, int maxlen, int type,
extern int parse_rtattr_flags(struct rtattr *tb[], int max, struct rtattr *rta, const void *data, int alen);
int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
int parse_rtattr_flags(struct rtattr *tb[], int max, struct rtattr *rta,
int len, unsigned short flags); int len, unsigned short flags);
extern int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int len); int parse_rtattr_byindex(struct rtattr *tb[], int max,
extern struct rtattr *parse_rtattr_one(int type, struct rtattr *rta, int len); struct rtattr *rta, int len);
extern int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rtattr *rta, int len); struct rtattr *parse_rtattr_one(int type, struct rtattr *rta, int len);
int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rtattr *rta, int len);
#define parse_rtattr_nested(tb, max, rta) \ #define parse_rtattr_nested(tb, max, rta) \
(parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta))) (parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta)))
...@@ -128,11 +131,11 @@ static inline const char *rta_getattr_str(const struct rtattr *rta) ...@@ -128,11 +131,11 @@ static inline const char *rta_getattr_str(const struct rtattr *rta)
return (const char *)RTA_DATA(rta); return (const char *)RTA_DATA(rta);
} }
extern int rtnl_listen_all_nsid(struct rtnl_handle *); int rtnl_listen_all_nsid(struct rtnl_handle *);
extern int rtnl_listen(struct rtnl_handle *, rtnl_listen_filter_t handler, int rtnl_listen(struct rtnl_handle *, rtnl_listen_filter_t handler,
void *jarg); void *jarg);
extern int rtnl_from_file(FILE *, rtnl_listen_filter_t handler, int rtnl_from_file(FILE *, rtnl_listen_filter_t handler,
void *jarg); void *jarg);
#define NLMSG_TAIL(nmsg) \ #define NLMSG_TAIL(nmsg) \
((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
......
#ifndef __LL_MAP_H__ #ifndef __LL_MAP_H__
#define __LL_MAP_H__ 1 #define __LL_MAP_H__ 1
extern int ll_remember_index(const struct sockaddr_nl *who, int ll_remember_index(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg); struct nlmsghdr *n, void *arg);
extern void ll_init_map(struct rtnl_handle *rth); void ll_init_map(struct rtnl_handle *rth);
extern unsigned ll_name_to_index(const char *name); unsigned ll_name_to_index(const char *name);
extern const char *ll_index_to_name(unsigned idx); const char *ll_index_to_name(unsigned idx);
extern const char *ll_idx_n2a(unsigned idx, char *buf); const char *ll_idx_n2a(unsigned idx, char *buf);
extern int ll_index_to_type(unsigned idx); int ll_index_to_type(unsigned idx);
extern int ll_index_to_flags(unsigned idx); int ll_index_to_flags(unsigned idx);
extern unsigned namehash(const char *str); unsigned namehash(const char *str);
#endif /* __LL_MAP_H__ */ #endif /* __LL_MAP_H__ */
...@@ -43,9 +43,9 @@ static inline int setns(int fd, int nstype) ...@@ -43,9 +43,9 @@ static inline int setns(int fd, int nstype)
} }
#endif /* HAVE_SETNS */ #endif /* HAVE_SETNS */
extern int netns_switch(char *netns); int netns_switch(char *netns);
extern int netns_get_fd(const char *netns); int netns_get_fd(const char *netns);
extern int netns_foreach(int (*func)(char *nsname, void *arg), void *arg); int netns_foreach(int (*func)(char *nsname, void *arg), void *arg);
struct netns_func { struct netns_func {
int (*func)(char *nsname, void *arg); int (*func)(char *nsname, void *arg);
......
...@@ -42,7 +42,7 @@ extern bool do_all; ...@@ -42,7 +42,7 @@ extern bool do_all;
#define SPRINT_BSIZE 64 #define SPRINT_BSIZE 64
#define SPRINT_BUF(x) char x[SPRINT_BSIZE] #define SPRINT_BUF(x) char x[SPRINT_BSIZE]
extern void incomplete_command(void) __attribute__((noreturn)); void incomplete_command(void) __attribute__((noreturn));
#define NEXT_ARG() do { argv++; if (--argc <= 0) incomplete_command(); } while(0) #define NEXT_ARG() do { argv++; if (--argc <= 0) incomplete_command(); } while(0)
#define NEXT_ARG_OK() (argc - 1 > 0) #define NEXT_ARG_OK() (argc - 1 > 0)
...@@ -85,47 +85,47 @@ struct ipx_addr { ...@@ -85,47 +85,47 @@ struct ipx_addr {
/* Maximum number of labels the mpls helpers support */ /* Maximum number of labels the mpls helpers support */
#define MPLS_MAX_LABELS 8 #define MPLS_MAX_LABELS 8
extern __u32 get_addr32(const char *name); __u32 get_addr32(const char *name);
extern int get_addr_1(inet_prefix *dst, const char *arg, int family); int get_addr_1(inet_prefix *dst, const char *arg, int family);
extern int get_prefix_1(inet_prefix *dst, char *arg, int family); int get_prefix_1(inet_prefix *dst, char *arg, int family);
extern int get_addr(inet_prefix *dst, const char *arg, int family); int get_addr(inet_prefix *dst, const char *arg, int family);
extern int get_prefix(inet_prefix *dst, char *arg, int family); int get_prefix(inet_prefix *dst, char *arg, int family);
extern int mask2bits(__u32 netmask); int mask2bits(__u32 netmask);
extern int get_integer(int *val, const char *arg, int base); int get_integer(int *val, const char *arg, int base);
extern int get_unsigned(unsigned *val, const char *arg, int base); int get_unsigned(unsigned *val, const char *arg, int base);
extern int get_time_rtt(unsigned *val, const char *arg, int *raw); int get_time_rtt(unsigned *val, const char *arg, int *raw);
#define get_byte get_u8 #define get_byte get_u8
#define get_ushort get_u16 #define get_ushort get_u16
#define get_short get_s16 #define get_short get_s16
extern int get_u64(__u64 *val, const char *arg, int base); int get_u64(__u64 *val, const char *arg, int base);
extern int get_u32(__u32 *val, const char *arg, int base); int get_u32(__u32 *val, const char *arg, int base);
extern int get_s32(__s32 *val, const char *arg, int base); int get_s32(__s32 *val, const char *arg, int base);
extern int get_u16(__u16 *val, const char *arg, int base); int get_u16(__u16 *val, const char *arg, int base);
extern int get_s16(__s16 *val, const char *arg, int base); int get_s16(__s16 *val, const char *arg, int base);
extern int get_u8(__u8 *val, const char *arg, int base); int get_u8(__u8 *val, const char *arg, int base);
extern int get_s8(__s8 *val, const char *arg, int base); int get_s8(__s8 *val, const char *arg, int base);
extern char* hexstring_n2a(const __u8 *str, int len, char *buf, int blen); char* hexstring_n2a(const __u8 *str, int len, char *buf, int blen);
extern __u8* hexstring_a2n(const char *str, __u8 *buf, int blen); __u8* hexstring_a2n(const char *str, __u8 *buf, int blen);
extern int af_bit_len(int af); int af_bit_len(int af);
extern int af_byte_len(int af); int af_byte_len(int af);
extern const char *format_host(int af, int len, const void *addr, const char *format_host(int af, int len, const void *addr,
char *buf, int buflen); char *buf, int buflen);
extern const char *rt_addr_n2a(int af, int len, const void *addr, const char *rt_addr_n2a(int af, int len, const void *addr,
char *buf, int buflen); char *buf, int buflen);
extern int read_family(const char *name); int read_family(const char *name);
extern const char *family_name(int family); const char *family_name(int family);
void missarg(const char *) __attribute__((noreturn)); void missarg(const char *) __attribute__((noreturn));
void invarg(const char *, const char *) __attribute__((noreturn)); void invarg(const char *, const char *) __attribute__((noreturn));
void duparg(const char *, const char *) __attribute__((noreturn)); void duparg(const char *, const char *) __attribute__((noreturn));
void duparg2(const char *, const char *) __attribute__((noreturn)); void duparg2(const char *, const char *) __attribute__((noreturn));
int matches(const char *arg, const char *pattern); int matches(const char *arg, const char *pattern);
extern int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits); int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits);
const char *dnet_ntop(int af, const void *addr, char *str, size_t len); const char *dnet_ntop(int af, const void *addr, char *str, size_t len);
int dnet_pton(int af, const char *src, void *addr); int dnet_pton(int af, const char *src, void *addr);
...@@ -137,7 +137,7 @@ const char *mpls_ntop(int af, const void *addr, char *str, size_t len); ...@@ -137,7 +137,7 @@ const char *mpls_ntop(int af, const void *addr, char *str, size_t len);
int mpls_pton(int af, const char *src, void *addr); int mpls_pton(int af, const char *src, void *addr);
extern int __iproute2_hz_internal; extern int __iproute2_hz_internal;
extern int __get_hz(void); int __get_hz(void);
static __inline__ int get_hz(void) static __inline__ int get_hz(void)
{ {
...@@ -147,7 +147,7 @@ static __inline__ int get_hz(void) ...@@ -147,7 +147,7 @@ static __inline__ int get_hz(void)
} }
extern int __iproute2_user_hz_internal; extern int __iproute2_user_hz_internal;
extern int __get_user_hz(void); int __get_user_hz(void);
static __inline__ int get_user_hz(void) static __inline__ int get_user_hz(void)
{ {
...@@ -191,16 +191,16 @@ void print_nlmsg_timestamp(FILE *fp, const struct nlmsghdr *n); ...@@ -191,16 +191,16 @@ void print_nlmsg_timestamp(FILE *fp, const struct nlmsghdr *n);
#endif #endif
extern int cmdlineno; extern int cmdlineno;
extern ssize_t getcmdline(char **line, size_t *len, FILE *in); ssize_t getcmdline(char **line, size_t *len, FILE *in);
extern int makeargs(char *line, char *argv[], int maxargs); int makeargs(char *line, char *argv[], int maxargs);
extern int inet_get_addr(const char *src, __u32 *dst, struct in6_addr *dst6); int inet_get_addr(const char *src, __u32 *dst, struct in6_addr *dst6);
struct iplink_req; struct iplink_req;
int iplink_parse(int argc, char **argv, struct iplink_req *req, int iplink_parse(int argc, char **argv, struct iplink_req *req,
char **name, char **type, char **link, char **dev, char **name, char **type, char **link, char **dev,
int *group, int *index); int *group, int *index);
extern int do_each_netns(int (*func)(char *nsname, void *arg), void *arg, int do_each_netns(int (*func)(char *nsname, void *arg), void *arg,
bool show_label); bool show_label);
char *int_to_str(int val, char *buf); char *int_to_str(int val, char *buf);
......
...@@ -48,8 +48,8 @@ static void usage(void) ...@@ -48,8 +48,8 @@ static void usage(void)
fprintf(stderr, fprintf(stderr,
"Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n" "Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n"
" ip [ -force ] -batch filename\n" " ip [ -force ] -batch filename\n"
"where OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable |\n" "where OBJECT := { link | address | addrlabel | route | rule | neighbor | ntable |\n"
" tunnel | tuntap | maddr | mroute | mrule | monitor | xfrm |\n" " tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |\n"
" netns | l2tp | fou | tcp_metrics | token | netconf }\n" " netns | l2tp | fou | tcp_metrics | token | netconf }\n"
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n" " OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
" -h[uman-readable] | -iec |\n" " -h[uman-readable] | -iec |\n"
......
...@@ -71,15 +71,15 @@ static void usage(void) ...@@ -71,15 +71,15 @@ static void usage(void)
if (do_link) { if (do_link) {
iplink_usage(); iplink_usage();
} }
fprintf(stderr, "Usage: ip addr {add|change|replace} IFADDR dev STRING [ LIFETIME ]\n"); fprintf(stderr, "Usage: ip address {add|change|replace} IFADDR dev IFNAME [ LIFETIME ]\n");
fprintf(stderr, " [ CONFFLAG-LIST ]\n"); fprintf(stderr, " [ CONFFLAG-LIST ]\n");
fprintf(stderr, " ip addr del IFADDR dev STRING [mngtmpaddr]\n"); fprintf(stderr, " ip address del IFADDR dev IFNAME [mngtmpaddr]\n");
fprintf(stderr, " ip addr {show|save|flush} [ dev STRING ] [ scope SCOPE-ID ]\n"); fprintf(stderr, " ip address {show|save|flush} [ dev IFNAME ] [ scope SCOPE-ID ]\n");
fprintf(stderr, " [ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ] [up]\n"); fprintf(stderr, " [ to PREFIX ] [ FLAG-LIST ] [ label LABEL ] [up]\n");
fprintf(stderr, " ip addr {showdump|restore}\n"); fprintf(stderr, " ip address {showdump|restore}\n");
fprintf(stderr, "IFADDR := PREFIX | ADDR peer PREFIX\n"); fprintf(stderr, "IFADDR := PREFIX | ADDR peer PREFIX\n");
fprintf(stderr, " [ broadcast ADDR ] [ anycast ADDR ]\n"); fprintf(stderr, " [ broadcast ADDR ] [ anycast ADDR ]\n");
fprintf(stderr, " [ label STRING ] [ scope SCOPE-ID ]\n"); fprintf(stderr, " [ label IFNAME ] [ scope SCOPE-ID ]\n");
fprintf(stderr, "SCOPE-ID := [ host | link | global | NUMBER ]\n"); fprintf(stderr, "SCOPE-ID := [ host | link | global | NUMBER ]\n");
fprintf(stderr, "FLAG-LIST := [ FLAG-LIST ] FLAG\n"); fprintf(stderr, "FLAG-LIST := [ FLAG-LIST ] FLAG\n");
fprintf(stderr, "FLAG := [ permanent | dynamic | secondary | primary |\n"); fprintf(stderr, "FLAG := [ permanent | dynamic | secondary | primary |\n");
...@@ -1131,7 +1131,7 @@ static int ipadd_dump_check_magic(void) ...@@ -1131,7 +1131,7 @@ static int ipadd_dump_check_magic(void)
__u32 magic = 0; __u32 magic = 0;
if (isatty(STDIN_FILENO)) { if (isatty(STDIN_FILENO)) {
fprintf(stderr, "Can't restore addr dump from a terminal\n"); fprintf(stderr, "Can't restore address dump from a terminal\n");
return -1; return -1;
} }
...@@ -1883,6 +1883,6 @@ int do_ipaddr(int argc, char **argv) ...@@ -1883,6 +1883,6 @@ int do_ipaddr(int argc, char **argv)
return ipaddr_restore(); return ipaddr_restore();
if (matches(*argv, "help") == 0) if (matches(*argv, "help") == 0)
usage(); usage();
fprintf(stderr, "Command \"%s\" is unknown, try \"ip addr help\".\n", *argv); fprintf(stderr, "Command \"%s\" is unknown, try \"ip address help\".\n", *argv);
exit(-1); exit(-1);
} }
...@@ -330,7 +330,7 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp, ...@@ -330,7 +330,7 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
else if (matches(*argv, "off") == 0) else if (matches(*argv, "off") == 0)
ivs.setting = 0; ivs.setting = 0;
else else
invarg("Invalid \"spoofchk\" value\n", *argv); return on_off("spoofchk", *argv);
ivs.vf = vf; ivs.vf = vf;
addattr_l(&req->n, sizeof(*req), IFLA_VF_SPOOFCHK, &ivs, sizeof(ivs)); addattr_l(&req->n, sizeof(*req), IFLA_VF_SPOOFCHK, &ivs, sizeof(ivs));
...@@ -342,7 +342,7 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp, ...@@ -342,7 +342,7 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
else if (matches(*argv, "off") == 0) else if (matches(*argv, "off") == 0)
ivs.setting = 0; ivs.setting = 0;
else else
invarg("Invalid \"query_rss\" value\n", *argv); return on_off("query_rss", *argv);
ivs.vf = vf; ivs.vf = vf;
addattr_l(&req->n, sizeof(*req), IFLA_VF_RSS_QUERY_EN, &ivs, sizeof(ivs)); addattr_l(&req->n, sizeof(*req), IFLA_VF_RSS_QUERY_EN, &ivs, sizeof(ivs));
...@@ -1105,7 +1105,7 @@ static int do_set(int argc, char **argv) ...@@ -1105,7 +1105,7 @@ static int do_set(int argc, char **argv)
} else if (strcmp(*argv, "off") == 0) { } else if (strcmp(*argv, "off") == 0) {
flags |= IFF_NOARP; flags |= IFF_NOARP;
} else } else
return on_off("noarp", *argv); return on_off("arp", *argv);
} else if (matches(*argv, "dynamic") == 0) { } else if (matches(*argv, "dynamic") == 0) {
NEXT_ARG(); NEXT_ARG();
mask |= IFF_DYNAMIC; mask |= IFF_DYNAMIC;
......
...@@ -171,10 +171,8 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -171,10 +171,8 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
while (argc > 0) { while (argc > 0) {
if (matches(*argv, "mode") == 0) { if (matches(*argv, "mode") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_index(mode_tbl, *argv) < 0) { if (get_index(mode_tbl, *argv) < 0)
invarg("invalid mode", *argv); invarg("invalid mode", *argv);
return -1;
}
mode = get_index(mode_tbl, *argv); mode = get_index(mode_tbl, *argv);
addattr8(n, 1024, IFLA_BOND_MODE, mode); addattr8(n, 1024, IFLA_BOND_MODE, mode);
} else if (matches(*argv, "active_slave") == 0) { } else if (matches(*argv, "active_slave") == 0) {
...@@ -187,38 +185,28 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -187,38 +185,28 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
addattr32(n, 1024, IFLA_BOND_ACTIVE_SLAVE, 0); addattr32(n, 1024, IFLA_BOND_ACTIVE_SLAVE, 0);
} else if (matches(*argv, "miimon") == 0) { } else if (matches(*argv, "miimon") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&miimon, *argv, 0)) { if (get_u32(&miimon, *argv, 0))
invarg("invalid miimon", *argv); invarg("invalid miimon", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BOND_MIIMON, miimon); addattr32(n, 1024, IFLA_BOND_MIIMON, miimon);
} else if (matches(*argv, "updelay") == 0) { } else if (matches(*argv, "updelay") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&updelay, *argv, 0)) { if (get_u32(&updelay, *argv, 0))
invarg("invalid updelay", *argv); invarg("invalid updelay", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BOND_UPDELAY, updelay); addattr32(n, 1024, IFLA_BOND_UPDELAY, updelay);
} else if (matches(*argv, "downdelay") == 0) { } else if (matches(*argv, "downdelay") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&downdelay, *argv, 0)) { if (get_u32(&downdelay, *argv, 0))
invarg("invalid downdelay", *argv); invarg("invalid downdelay", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BOND_DOWNDELAY, downdelay); addattr32(n, 1024, IFLA_BOND_DOWNDELAY, downdelay);
} else if (matches(*argv, "use_carrier") == 0) { } else if (matches(*argv, "use_carrier") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u8(&use_carrier, *argv, 0)) { if (get_u8(&use_carrier, *argv, 0))
invarg("invalid use_carrier", *argv); invarg("invalid use_carrier", *argv);
return -1;
}
addattr8(n, 1024, IFLA_BOND_USE_CARRIER, use_carrier); addattr8(n, 1024, IFLA_BOND_USE_CARRIER, use_carrier);
} else if (matches(*argv, "arp_interval") == 0) { } else if (matches(*argv, "arp_interval") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&arp_interval, *argv, 0)) { if (get_u32(&arp_interval, *argv, 0))
invarg("invalid arp_interval", *argv); invarg("invalid arp_interval", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BOND_ARP_INTERVAL, arp_interval); addattr32(n, 1024, IFLA_BOND_ARP_INTERVAL, arp_interval);
} else if (matches(*argv, "arp_ip_target") == 0) { } else if (matches(*argv, "arp_ip_target") == 0) {
struct rtattr * nest = addattr_nest(n, 1024, struct rtattr * nest = addattr_nest(n, 1024,
...@@ -239,18 +227,14 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -239,18 +227,14 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
addattr_nest_end(n, nest); addattr_nest_end(n, nest);
} else if (matches(*argv, "arp_validate") == 0) { } else if (matches(*argv, "arp_validate") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_index(arp_validate_tbl, *argv) < 0) { if (get_index(arp_validate_tbl, *argv) < 0)
invarg("invalid arp_validate", *argv); invarg("invalid arp_validate", *argv);
return -1;
}
arp_validate = get_index(arp_validate_tbl, *argv); arp_validate = get_index(arp_validate_tbl, *argv);
addattr32(n, 1024, IFLA_BOND_ARP_VALIDATE, arp_validate); addattr32(n, 1024, IFLA_BOND_ARP_VALIDATE, arp_validate);
} else if (matches(*argv, "arp_all_targets") == 0) { } else if (matches(*argv, "arp_all_targets") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_index(arp_all_targets_tbl, *argv) < 0) { if (get_index(arp_all_targets_tbl, *argv) < 0)
invarg("invalid arp_all_targets", *argv); invarg("invalid arp_all_targets", *argv);
return -1;
}
arp_all_targets = get_index(arp_all_targets_tbl, *argv); arp_all_targets = get_index(arp_all_targets_tbl, *argv);
addattr32(n, 1024, IFLA_BOND_ARP_ALL_TARGETS, arp_all_targets); addattr32(n, 1024, IFLA_BOND_ARP_ALL_TARGETS, arp_all_targets);
} else if (matches(*argv, "primary") == 0) { } else if (matches(*argv, "primary") == 0) {
...@@ -261,108 +245,93 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -261,108 +245,93 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
addattr32(n, 1024, IFLA_BOND_PRIMARY, ifindex); addattr32(n, 1024, IFLA_BOND_PRIMARY, ifindex);
} else if (matches(*argv, "primary_reselect") == 0) { } else if (matches(*argv, "primary_reselect") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_index(primary_reselect_tbl, *argv) < 0) { if (get_index(primary_reselect_tbl, *argv) < 0)
invarg("invalid primary_reselect", *argv); invarg("invalid primary_reselect", *argv);
return -1;
}
primary_reselect = get_index(primary_reselect_tbl, *argv); primary_reselect = get_index(primary_reselect_tbl, *argv);
addattr8(n, 1024, IFLA_BOND_PRIMARY_RESELECT, addattr8(n, 1024, IFLA_BOND_PRIMARY_RESELECT,
primary_reselect); primary_reselect);
} else if (matches(*argv, "fail_over_mac") == 0) { } else if (matches(*argv, "fail_over_mac") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_index(fail_over_mac_tbl, *argv) < 0) { if (get_index(fail_over_mac_tbl, *argv) < 0)
invarg("invalid fail_over_mac", *argv); invarg("invalid fail_over_mac", *argv);
return -1;
}
fail_over_mac = get_index(fail_over_mac_tbl, *argv); fail_over_mac = get_index(fail_over_mac_tbl, *argv);
addattr8(n, 1024, IFLA_BOND_FAIL_OVER_MAC, addattr8(n, 1024, IFLA_BOND_FAIL_OVER_MAC,
fail_over_mac); fail_over_mac);
} else if (matches(*argv, "xmit_hash_policy") == 0) { } else if (matches(*argv, "xmit_hash_policy") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_index(xmit_hash_policy_tbl, *argv) < 0) { if (get_index(xmit_hash_policy_tbl, *argv) < 0)
invarg("invalid xmit_hash_policy", *argv); invarg("invalid xmit_hash_policy", *argv);
return -1;
}
xmit_hash_policy = get_index(xmit_hash_policy_tbl, *argv); xmit_hash_policy = get_index(xmit_hash_policy_tbl, *argv);
addattr8(n, 1024, IFLA_BOND_XMIT_HASH_POLICY, addattr8(n, 1024, IFLA_BOND_XMIT_HASH_POLICY,
xmit_hash_policy); xmit_hash_policy);
} else if (matches(*argv, "resend_igmp") == 0) { } else if (matches(*argv, "resend_igmp") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&resend_igmp, *argv, 0)) { if (get_u32(&resend_igmp, *argv, 0))
invarg("invalid resend_igmp", *argv); invarg("invalid resend_igmp", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BOND_RESEND_IGMP, resend_igmp); addattr32(n, 1024, IFLA_BOND_RESEND_IGMP, resend_igmp);
} else if (matches(*argv, "num_grat_arp") == 0 || } else if (matches(*argv, "num_grat_arp") == 0 ||
matches(*argv, "num_unsol_na") == 0) { matches(*argv, "num_unsol_na") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u8(&num_peer_notif, *argv, 0)) { if (get_u8(&num_peer_notif, *argv, 0))
invarg("invalid num_grat_arp|num_unsol_na", invarg("invalid num_grat_arp|num_unsol_na",
*argv); *argv);
return -1;
}
addattr8(n, 1024, IFLA_BOND_NUM_PEER_NOTIF, addattr8(n, 1024, IFLA_BOND_NUM_PEER_NOTIF,
num_peer_notif); num_peer_notif);
} else if (matches(*argv, "all_slaves_active") == 0) { } else if (matches(*argv, "all_slaves_active") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u8(&all_slaves_active, *argv, 0)) { if (get_u8(&all_slaves_active, *argv, 0))
invarg("invalid all_slaves_active", *argv); invarg("invalid all_slaves_active", *argv);
return -1;
}
addattr8(n, 1024, IFLA_BOND_ALL_SLAVES_ACTIVE, addattr8(n, 1024, IFLA_BOND_ALL_SLAVES_ACTIVE,
all_slaves_active); all_slaves_active);
} else if (matches(*argv, "min_links") == 0) { } else if (matches(*argv, "min_links") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&min_links, *argv, 0)) { if (get_u32(&min_links, *argv, 0))
invarg("invalid min_links", *argv); invarg("invalid min_links", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BOND_MIN_LINKS, min_links); addattr32(n, 1024, IFLA_BOND_MIN_LINKS, min_links);
} else if (matches(*argv, "lp_interval") == 0) { } else if (matches(*argv, "lp_interval") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&lp_interval, *argv, 0)) { if (get_u32(&lp_interval, *argv, 0))
invarg("invalid lp_interval", *argv); invarg("invalid lp_interval", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BOND_LP_INTERVAL, lp_interval); addattr32(n, 1024, IFLA_BOND_LP_INTERVAL, lp_interval);
} else if (matches(*argv, "packets_per_slave") == 0) { } else if (matches(*argv, "packets_per_slave") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&packets_per_slave, *argv, 0)) { if (get_u32(&packets_per_slave, *argv, 0))
invarg("invalid packets_per_slave", *argv); invarg("invalid packets_per_slave", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BOND_PACKETS_PER_SLAVE, addattr32(n, 1024, IFLA_BOND_PACKETS_PER_SLAVE,
packets_per_slave); packets_per_slave);
} else if (matches(*argv, "lacp_rate") == 0) { } else if (matches(*argv, "lacp_rate") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_index(lacp_rate_tbl, *argv) < 0) { if (get_index(lacp_rate_tbl, *argv) < 0)
invarg("invalid lacp_rate", *argv); invarg("invalid lacp_rate", *argv);
return -1;
}
lacp_rate = get_index(lacp_rate_tbl, *argv); lacp_rate = get_index(lacp_rate_tbl, *argv);
addattr8(n, 1024, IFLA_BOND_AD_LACP_RATE, lacp_rate); addattr8(n, 1024, IFLA_BOND_AD_LACP_RATE, lacp_rate);
} else if (matches(*argv, "ad_select") == 0) { } else if (matches(*argv, "ad_select") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_index(ad_select_tbl, *argv) < 0) { if (get_index(ad_select_tbl, *argv) < 0)
invarg("invalid ad_select", *argv); invarg("invalid ad_select", *argv);
return -1;
}
ad_select = get_index(ad_select_tbl, *argv); ad_select = get_index(ad_select_tbl, *argv);
addattr8(n, 1024, IFLA_BOND_AD_SELECT, ad_select); addattr8(n, 1024, IFLA_BOND_AD_SELECT, ad_select);
} else if (matches(*argv, "ad_user_port_key") == 0) { } else if (matches(*argv, "ad_user_port_key") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u16(&ad_user_port_key, *argv, 0)) { if (get_u16(&ad_user_port_key, *argv, 0))
invarg("invalid ad_user_port_key", *argv); invarg("invalid ad_user_port_key", *argv);
return -1;
}
addattr16(n, 1024, IFLA_BOND_AD_USER_PORT_KEY, addattr16(n, 1024, IFLA_BOND_AD_USER_PORT_KEY,
ad_user_port_key); ad_user_port_key);
} else if (matches(*argv, "ad_actor_sys_prio") == 0) { } else if (matches(*argv, "ad_actor_sys_prio") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u16(&ad_actor_sys_prio, *argv, 0)) { if (get_u16(&ad_actor_sys_prio, *argv, 0))
invarg("invalid ad_actor_sys_prio", *argv); invarg("invalid ad_actor_sys_prio", *argv);
return -1;
}
addattr16(n, 1024, IFLA_BOND_AD_ACTOR_SYS_PRIO, addattr16(n, 1024, IFLA_BOND_AD_ACTOR_SYS_PRIO,
ad_actor_sys_prio); ad_actor_sys_prio);
} else if (matches(*argv, "ad_actor_system") == 0) { } else if (matches(*argv, "ad_actor_system") == 0) {
......
...@@ -43,47 +43,41 @@ static int bridge_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -43,47 +43,41 @@ static int bridge_parse_opt(struct link_util *lu, int argc, char **argv,
while (argc > 0) { while (argc > 0) {
if (matches(*argv, "forward_delay") == 0) { if (matches(*argv, "forward_delay") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&val, *argv, 0)) { if (get_u32(&val, *argv, 0))
invarg("invalid forward_delay", *argv); invarg("invalid forward_delay", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BR_FORWARD_DELAY, val); addattr32(n, 1024, IFLA_BR_FORWARD_DELAY, val);
} else if (matches(*argv, "hello_time") == 0) { } else if (matches(*argv, "hello_time") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&val, *argv, 0)) { if (get_u32(&val, *argv, 0))
invarg("invalid hello_time", *argv); invarg("invalid hello_time", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BR_HELLO_TIME, val); addattr32(n, 1024, IFLA_BR_HELLO_TIME, val);
} else if (matches(*argv, "max_age") == 0) { } else if (matches(*argv, "max_age") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&val, *argv, 0)) { if (get_u32(&val, *argv, 0))
invarg("invalid max_age", *argv); invarg("invalid max_age", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BR_MAX_AGE, val); addattr32(n, 1024, IFLA_BR_MAX_AGE, val);
} else if (matches(*argv, "ageing_time") == 0) { } else if (matches(*argv, "ageing_time") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&val, *argv, 0)) { if (get_u32(&val, *argv, 0))
invarg("invalid ageing_time", *argv); invarg("invalid ageing_time", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BR_AGEING_TIME, val); addattr32(n, 1024, IFLA_BR_AGEING_TIME, val);
} else if (matches(*argv, "stp_state") == 0) { } else if (matches(*argv, "stp_state") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&val, *argv, 0)) { if (get_u32(&val, *argv, 0))
invarg("invalid stp_state", *argv); invarg("invalid stp_state", *argv);
return -1;
}
addattr32(n, 1024, IFLA_BR_STP_STATE, val); addattr32(n, 1024, IFLA_BR_STP_STATE, val);
} else if (matches(*argv, "priority") == 0) { } else if (matches(*argv, "priority") == 0) {
__u16 prio; __u16 prio;
NEXT_ARG(); NEXT_ARG();
if (get_u16(&prio, *argv, 0)) { if (get_u16(&prio, *argv, 0))
invarg("invalid priority", *argv); invarg("invalid priority", *argv);
return -1;
}
addattr16(n, 1024, IFLA_BR_PRIORITY, prio); addattr16(n, 1024, IFLA_BR_PRIORITY, prio);
} else if (matches(*argv, "vlan_filtering") == 0) { } else if (matches(*argv, "vlan_filtering") == 0) {
__u8 vlan_filter; __u8 vlan_filter;
......
...@@ -58,32 +58,35 @@ int netns_switch(char *name) ...@@ -58,32 +58,35 @@ int netns_switch(char *name)
if (setns(netns, CLONE_NEWNET) < 0) { if (setns(netns, CLONE_NEWNET) < 0) {
fprintf(stderr, "setting the network namespace \"%s\" failed: %s\n", fprintf(stderr, "setting the network namespace \"%s\" failed: %s\n",
name, strerror(errno)); name, strerror(errno));
return -1; goto fail_close;
} }
if (unshare(CLONE_NEWNS) < 0) { if (unshare(CLONE_NEWNS) < 0) {
fprintf(stderr, "unshare failed: %s\n", strerror(errno)); fprintf(stderr, "unshare failed: %s\n", strerror(errno));
return -1; goto fail_close;
} }
/* Don't let any mounts propagate back to the parent */ /* Don't let any mounts propagate back to the parent */
if (mount("", "/", "none", MS_SLAVE | MS_REC, NULL)) { if (mount("", "/", "none", MS_SLAVE | MS_REC, NULL)) {
fprintf(stderr, "\"mount --make-rslave /\" failed: %s\n", fprintf(stderr, "\"mount --make-rslave /\" failed: %s\n",
strerror(errno)); strerror(errno));
return -1; goto fail_close;
} }
/* Mount a version of /sys that describes the network namespace */ /* Mount a version of /sys that describes the network namespace */
if (umount2("/sys", MNT_DETACH) < 0) { if (umount2("/sys", MNT_DETACH) < 0) {
fprintf(stderr, "umount of /sys failed: %s\n", strerror(errno)); fprintf(stderr, "umount of /sys failed: %s\n", strerror(errno));
return -1; goto fail_close;
} }
if (mount(name, "/sys", "sysfs", 0, NULL) < 0) { if (mount(name, "/sys", "sysfs", 0, NULL) < 0) {
fprintf(stderr, "mount of /sys failed: %s\n",strerror(errno)); fprintf(stderr, "mount of /sys failed: %s\n",strerror(errno));
return -1; goto fail_close;
} }
/* Setup bind mounts for config files in /etc */ /* Setup bind mounts for config files in /etc */
bind_etc(name); bind_etc(name);
return 0; return 0;
fail_close:
close(netns);
return -1;
} }
int netns_get_fd(const char *name) int netns_get_fd(const char *name)
......
...@@ -14,18 +14,26 @@ ip-address \- protocol address management ...@@ -14,18 +14,26 @@ ip-address \- protocol address management
.sp .sp
.ti -8 .ti -8
.BR "ip address" " { " add " | " del " } " .BR "ip address" " { " add " | " change " | " replace " } "
.IB IFADDR " dev " STRING .IB IFADDR " dev " IFNAME
.RI "[ " LIFETIME " ] [ " CONFFLAG-LIST " ]"
.ti -8 .ti -8
.BR "ip address" " { " show " | " flush " } [ " dev .BR "ip address del"
.IR STRING " ] [ " .IB IFADDR " dev " IFNAME " [ " mngtmpaddr " ]"
.ti -8
.BR "ip address" " { " show " | " save " | " flush " } [ " dev
.IR IFNAME " ] [ "
.B scope .B scope
.IR SCOPE-ID " ] [ " .IR SCOPE-ID " ] [ "
.B to .B to
.IR PREFIX " ] [ " FLAG-LIST " ] [ " .IR PREFIX " ] [ " FLAG-LIST " ] [ "
.B label .B label
.IR PATTERN " ]" .IR PATTERN " ] [ " up " ]"
.ti -8
.BR "ip address" " { " showdump " | " restore " }"
.ti -8 .ti -8
.IR IFADDR " := " PREFIX " | " ADDR .IR IFADDR " := " PREFIX " | " ADDR
...@@ -36,7 +44,7 @@ ip-address \- protocol address management ...@@ -36,7 +44,7 @@ ip-address \- protocol address management
.B anycast .B anycast
.IR ADDR " ] [ " .IR ADDR " ] [ "
.B label .B label
.IR STRING " ] [ " .IR LABEL " ] [ "
.B scope .B scope
.IR SCOPE-ID " ]" .IR SCOPE-ID " ]"
...@@ -52,15 +60,33 @@ ip-address \- protocol address management ...@@ -52,15 +60,33 @@ ip-address \- protocol address management
.IR FLAG " := " .IR FLAG " := "
.RB "[ " permanent " | " dynamic " | " secondary " | " primary " | \ .RB "[ " permanent " | " dynamic " | " secondary " | " primary " | \
[ - ] " tentative " | [ - ] " deprecated " | [ - ] " dadfailed " | "\ [ - ] " tentative " | [ - ] " deprecated " | [ - ] " dadfailed " | "\
temporary " ]" temporary " ] " CONFFLAG-LIST " ]"
.ti -8
.IR CONFFLAG-LIST " := [ " CONFFLAG-LIST " ] " CONFFLAG
.ti -8
.IR CONFFLAG " := "
.RB "[ " home " | " nodad " ]"
.ti -8
.IR LIFETIME " := [ "
.BI valid_lft " LFT"
.RB "| " preferred_lft
.IR LFT " ]"
.ti -8
.IR LFT " := [ "
.BR forever " |"
.IR SECONDS " ]"
.SH "DESCRIPTION" .SH "DESCRIPTION"
The The
.B address .B address
is a protocol (IP or IPv6) address attached is a protocol (IPv4 or IPv6) address attached
to a network device. Each device must have at least one address to a network device. Each device must have at least one address
to use the corresponding protocol. It is possible to have several to use the corresponding protocol. It is possible to have several
different addresses attached to one device. These addresses are not different addresses attached to one device. These addresses are not
discriminated, so that the term discriminated, so that the term
.B alias .B alias
is not quite appropriate for them and we do not use it in this document. is not quite appropriate for them and we do not use it in this document.
...@@ -73,7 +99,7 @@ and deletes old ones. ...@@ -73,7 +99,7 @@ and deletes old ones.
.SS ip address add - add new protocol address. .SS ip address add - add new protocol address.
.TP .TP
.BI dev " NAME" .BI dev " IFNAME "
the name of the device to add the address to. the name of the device to add the address to.
.TP .TP
...@@ -107,7 +133,7 @@ instead of the broadcast address. In this case, the broadcast address ...@@ -107,7 +133,7 @@ instead of the broadcast address. In this case, the broadcast address
is derived by setting/resetting the host bits of the interface prefix. is derived by setting/resetting the host bits of the interface prefix.
.TP .TP
.BI label " NAME" .BI label " LABEL"
Each address may be tagged with a label string. Each address may be tagged with a label string.
In order to preserve compatibility with Linux-2.0 net aliases, In order to preserve compatibility with Linux-2.0 net aliases,
this string must coincide with the name of the device or must be prefixed this string must coincide with the name of the device or must be prefixed
...@@ -125,7 +151,7 @@ Predefined scope values are: ...@@ -125,7 +151,7 @@ Predefined scope values are:
- the address is globally valid. - the address is globally valid.
.sp .sp
.B site .B site
- (IPv6 only) the address is site local, i.e. it is - (IPv6 only, deprecated) the address is site local, i.e. it is
valid inside this site. valid inside this site.
.sp .sp
.B link .B link
...@@ -135,6 +161,30 @@ valid inside this site. ...@@ -135,6 +161,30 @@ valid inside this site.
- the address is valid only inside this host. - the address is valid only inside this host.
.in -8 .in -8
.TP
.BI valid_lft " LFT"
the valid lifetime of this address; see section 5.5.4 of
RFC 4862. When it expires, the address is removed by the kernel.
Defaults to
.BR "forever" .
.TP
.BI preferred_lft " LFT"
the preferred lifetime of this address; see section 5.5.4
of RFC 4862. When it expires, the address is no longer used for new
outgoing connections. Defaults to
.BR "forever" .
.TP
.B home
(IPv6 only) designates this address the "home address" as defined in
RFC 6275.
.TP
.B nodad
(IPv6 only) do not perform Duplicate Address Detection (RFC 4862) when
adding this address.
.SS ip address delete - delete protocol address .SS ip address delete - delete protocol address
.B Arguments: .B Arguments:
coincide with the arguments of coincide with the arguments of
...@@ -145,7 +195,7 @@ If no arguments are given, the first address is deleted. ...@@ -145,7 +195,7 @@ If no arguments are given, the first address is deleted.
.SS ip address show - look at protocol addresses .SS ip address show - look at protocol addresses
.TP .TP
.BI dev " NAME " (default) .BI dev " IFNAME " (default)
name of device. name of device.
.TP .TP
...@@ -219,36 +269,53 @@ The difference is that it does not run when no arguments are given. ...@@ -219,36 +269,53 @@ The difference is that it does not run when no arguments are given.
.PP .PP
.B Warning: .B Warning:
This command (and other This command and other
.B flush .B flush
commands described below) is pretty dangerous. If you make a mistake, commands are unforgiving. They will cruelly purge all the addresses.
it will not forgive it, but will cruelly purge all the addresses.
.PP .PP
With the With the
.B -statistics .B -statistics
option, the command becomes verbose. It prints out the number of deleted option, the command becomes verbose. It prints out the number of deleted
addresses and the number of rounds made to flush the address list. If addresses and the number of rounds made to flush the address list.
this option is given twice, If this option is given twice,
.B ip address flush .B ip address flush
also dumps all the deleted addresses in the format described in the also dumps all the deleted addresses in the format described in the
previous subsection. previous subsection.
.SH "EXAMPLES" .SH "EXAMPLES"
.PP .PP
ip address show
.RS 4
Shows IPv4 and IPv6 addresses assigned to all network interfaces. The 'show'
subcommand can be omitted.
.RE
.PP
ip address show up
.RS 4
Same as above except that only addresses assigned to active network interfaces
are shown.
.RE
.PP
ip address show dev eth0 ip address show dev eth0
.RS 4 .RS 4
Shows the addresses assigned to network interface eth0 Shows IPv4 and IPv6 addresses assigned to network interface eth0.
.RE
.PP
ip address add 2001:0db8:85a3::0370:7334/64 dev eth1
.RS 4
Adds an IPv6 address to network interface eth1.
.RE .RE
.PP .PP
ip addr add 2001:0db8:85a3::0370:7334/64 dev eth1 ip address delete 2001:0db8:85a3::0370:7334/64 dev eth1
.RS 4 .RS 4
Adds an IPv6 address to network interface eth1 Delete the IPv6 address added above.
.RE .RE
.PP .PP
ip addr flush dev eth4 ip address flush dev eth4 scope global
.RS 4 .RS 4
Removes all addresses from device eth4 Removes all global IPv4 and IPv6 addresses from device eth4. Without 'scope
global' it would remove all addresses including IPv6 link-local ones.
.RE .RE
.SH SEE ALSO .SH SEE ALSO
......
...@@ -145,9 +145,13 @@ ip-link \- network device configuration ...@@ -145,9 +145,13 @@ ip-link \- network device configuration
] | ] |
.br .br
.B master .B master
.IR DEVICE .IR DEVICE " |"
.br .br
.B nomaster .B nomaster " |"
.br
.B addrgenmode { eui64 | none }
.br
.B link-netnsid ID
.BR " }" .BR " }"
...@@ -187,6 +191,8 @@ Link types: ...@@ -187,6 +191,8 @@ Link types:
.sp .sp
.B bond .B bond
- Bonding device - Bonding device
.B can
- Controller Area Network interface
.sp .sp
.B dummy .B dummy
- Dummy network interface - Dummy network interface
...@@ -267,6 +273,66 @@ specifies the number of receive queues for new device. ...@@ -267,6 +273,66 @@ specifies the number of receive queues for new device.
.BI index " IDX " .BI index " IDX "
specifies the desired index of the new virtual device. The link creation fails, if the index is busy. specifies the desired index of the new virtual device. The link creation fails, if the index is busy.
.TP
VLAN Type Support
For a link of type
.I VLAN
the following additional arguments are supported:
.BI "ip link add
.BI link " DEVICE "
.BI name " NAME "
.BI type " vlan "
.R " [ "
.BI protocol " VLAN_PROTO "
.R " ] "
.BI id " VLANID "
.R " [ "
.BR reorder_hdr " { " on " | " off " } "
.R " ] "
.R " [ "
.BR gvrp " { " on " | " off " } "
.R " ] "
.R " [ "
.BR mvrp " { " on " | " off " } "
.R " ] "
.R " [ "
.BR loose_binding " { " on " | " off " } "
.R " ] "
.R " [ "
.BI ingress-qos-map " QOS-MAP "
.R " ] "
.R " [ "
.BI egress-qos-map " QOS-MAP "
.R " ] "
.in +8
.sp
.BI protocol " VLAN_PROTO "
- either 802.1Q or 802.1ad.
.BI id " VLANID "
- specifies the VLAN Identifer to use. Note that numbers with a leading " 0 " or " 0x " are interpreted as octal or hexadeimal, respectively.
.BR reorder_hdr " { " on " | " off " } "
- specifies whether ethernet headers are reordered or not.
.BR gvrp " { " on " | " off " } "
- specifies whether this VLAN should be registered using GARP VLAN Registration Protocol.
.BR mvrp " { " on " | " off " } "
- specifies whether this VLAN should be registered using Multiple VLAN Registration Protocol.
.BR loose_binding " { " on " | " off " } "
- specifies whether the VLAN device state is bound to the physical device state.
.BI ingress-qos-map " QOS-MAP "
- defines a mapping between priority code points on incoming frames. The format is FROM:TO with multiple mappings separated by spaces.
.BI egress-qos-map " QOS-MAP "
- the same as ingress-qos-map but for outgoing frames.
.in -8
.TP .TP
VXLAN Type Support VXLAN Type Support
For a link of type For a link of type
...@@ -286,7 +352,9 @@ the following additional arguments are supported: ...@@ -286,7 +352,9 @@ the following additional arguments are supported:
.R " ] [ " .R " ] [ "
.BI tos " TOS " .BI tos " TOS "
.R " ] [ " .R " ] [ "
.BI port " MIN MAX " .BI dstport " PORT "
.R " ] [ "
.BI srcport " MIN MAX "
.R " ] [ " .R " ] [ "
.I "[no]learning " .I "[no]learning "
.R " ] [ " .R " ] [ "
...@@ -298,6 +366,12 @@ the following additional arguments are supported: ...@@ -298,6 +366,12 @@ the following additional arguments are supported:
.R " ] [ " .R " ] [ "
.I "[no]l3miss " .I "[no]l3miss "
.R " ] [ " .R " ] [ "
.I "[no]udpcsum "
.R " ] [ "
.I "[no]udp6zerocsumtx "
.R " ] [ "
.I "[no]udp6zerocsumrx "
.R " ] [ "
.BI ageing " SECONDS " .BI ageing " SECONDS "
.R " ] [ " .R " ] [ "
.BI maxaddress " NUMBER " .BI maxaddress " NUMBER "
...@@ -342,7 +416,11 @@ parameter. ...@@ -342,7 +416,11 @@ parameter.
- specifies the TOS value to use in outgoing packets. - specifies the TOS value to use in outgoing packets.
.sp .sp
.BI port " MIN MAX" .BI dstport " PORT"
- specifies the UDP destination port to communicate to the remote VXLAN tunnel endpoint.
.sp
.BI srcport " MIN MAX"
- specifies the range of port numbers to use as UDP - specifies the range of port numbers to use as UDP
source ports to communicate to the remote VXLAN tunnel endpoint. source ports to communicate to the remote VXLAN tunnel endpoint.
...@@ -367,6 +445,18 @@ are entered into the VXLAN device forwarding database. ...@@ -367,6 +445,18 @@ are entered into the VXLAN device forwarding database.
.I [no]l3miss .I [no]l3miss
- specifies if netlink IP ADDR miss notifications are generated. - specifies if netlink IP ADDR miss notifications are generated.
.sp
.I [no]udpcsum
- specifies if UDP checksum is filled in
.sp
.I [no]udp6zerocsumtx
- specifies if UDP checksum is filled in
.sp
.I [no]udp6zerocsumrx
- specifies if UDP checksum is received
.sp .sp
.BI ageing " SECONDS" .BI ageing " SECONDS"
- specifies the lifetime in seconds of FDB entries learnt by the kernel. - specifies the lifetime in seconds of FDB entries learnt by the kernel.
...@@ -758,6 +848,12 @@ tool can be used. But it allows to change network namespace only for physical de ...@@ -758,6 +848,12 @@ tool can be used. But it allows to change network namespace only for physical de
.BI alias " NAME" .BI alias " NAME"
give the device a symbolic name for easy reference. give the device a symbolic name for easy reference.
.TP
.BI group " GROUP"
specify the group the device belongs to.
The available groups are listed in file
.BR "@SYSCONFDIR@/group" .
.TP .TP
.BI vf " NUM" .BI vf " NUM"
specify a Virtual Function device to be configured. The associated PF device specify a Virtual Function device to be configured. The associated PF device
...@@ -837,6 +933,14 @@ set master device of the device (enslave device). ...@@ -837,6 +933,14 @@ set master device of the device (enslave device).
.BI nomaster .BI nomaster
unset master device of the device (release device). unset master device of the device (release device).
.TP
.BR "addrgenmode eui64 " or " addrgenmode none"
set IPv6 address generation mode
.TP
.BR "link-netnsid "
set peer netnsid for a cross-netns interface
.PP .PP
.B Warning: .B Warning:
If multiple parameter changes are requested, If multiple parameter changes are requested,
......
...@@ -19,8 +19,8 @@ ip \- show / manipulate routing, devices, policy routing and tunnels ...@@ -19,8 +19,8 @@ ip \- show / manipulate routing, devices, policy routing and tunnels
.ti -8 .ti -8
.IR OBJECT " := { " .IR OBJECT " := { "
.BR link " | " addr " | " addrlabel " | " route " | " rule " | " neigh " | "\ .BR link " | " address " | " addrlabel " | " route " | " rule " | " neigh " | "\
ntable " | " tunnel " | " tuntap " | " maddr " | " mroute " | " mrule " | "\ ntable " | " tunnel " | " tuntap " | " maddress " | " mroute " | " mrule " | "\
monitor " | " xfrm " | " netns " | " l2tp " | " tcp_metrics " }" monitor " | " xfrm " | " netns " | " l2tp " | " tcp_metrics " }"
.sp .sp
...@@ -67,7 +67,7 @@ Output more detailed information. ...@@ -67,7 +67,7 @@ Output more detailed information.
.TP .TP
.BR "\-l" , " \-loops " <COUNT> .BR "\-l" , " \-loops " <COUNT>
Specify maximum number of loops the 'ip addr flush' logic Specify maximum number of loops the 'ip address flush' logic
will attempt before giving up. The default is 10. will attempt before giving up. The default is 10.
Zero (0) means loop until all addresses are removed. Zero (0) means loop until all addresses are removed.
...@@ -143,7 +143,7 @@ use the system's name resolver to print DNS names instead of ...@@ -143,7 +143,7 @@ use the system's name resolver to print DNS names instead of
host addresses. host addresses.
.TP .TP
.BR "\-n" , " \-net" , " \-netns " <NETNS> .BR "\-n" , " \-netns " <NETNS>
switches switches
.B ip .B ip
to the specified network namespace to the specified network namespace
......
...@@ -483,8 +483,10 @@ static void user_ent_hash_build(void) ...@@ -483,8 +483,10 @@ static void user_ent_hash_build(void)
sprintf(name + nameoff, "%d/fd/", pid); sprintf(name + nameoff, "%d/fd/", pid);
pos = strlen(name); pos = strlen(name);
if ((dir1 = opendir(name)) == NULL) if ((dir1 = opendir(name)) == NULL) {
free(pid_context);
continue; continue;
}
process[0] = '\0'; process[0] = '\0';
p = process; p = process;
...@@ -550,7 +552,7 @@ static int find_entry(unsigned ino, char **buf, int type) ...@@ -550,7 +552,7 @@ static int find_entry(unsigned ino, char **buf, int type)
struct user_ent *p; struct user_ent *p;
int cnt = 0; int cnt = 0;
char *ptr; char *ptr;
char **new_buf = buf; char *new_buf;
int len, new_buf_len; int len, new_buf_len;
int buf_used = 0; int buf_used = 0;
int buf_len = 0; int buf_len = 0;
...@@ -592,12 +594,12 @@ static int find_entry(unsigned ino, char **buf, int type) ...@@ -592,12 +594,12 @@ static int find_entry(unsigned ino, char **buf, int type)
if (len < 0 || len >= buf_len - buf_used) { if (len < 0 || len >= buf_len - buf_used) {
new_buf_len = buf_len + ENTRY_BUF_SIZE; new_buf_len = buf_len + ENTRY_BUF_SIZE;
*new_buf = realloc(*buf, new_buf_len); new_buf = realloc(*buf, new_buf_len);
if (!new_buf) { if (!new_buf) {
fprintf(stderr, "ss: failed to malloc buffer\n"); fprintf(stderr, "ss: failed to malloc buffer\n");
abort(); abort();
} }
**buf = **new_buf; *buf = new_buf;
buf_len = new_buf_len; buf_len = new_buf_len;
continue; continue;
} else { } else {
...@@ -3025,6 +3027,7 @@ static int packet_show_line(char *buf, const struct filter *f, int fam) ...@@ -3025,6 +3027,7 @@ static int packet_show_line(char *buf, const struct filter *f, int fam)
static int packet_show(struct filter *f) static int packet_show(struct filter *f)
{ {
FILE *fp; FILE *fp;
int rc = 0;
if (!filter_af_get(f, AF_PACKET) || !(f->states & (1 << SS_CLOSE))) if (!filter_af_get(f, AF_PACKET) || !(f->states & (1 << SS_CLOSE)))
return 0; return 0;
...@@ -3036,9 +3039,10 @@ static int packet_show(struct filter *f) ...@@ -3036,9 +3039,10 @@ static int packet_show(struct filter *f)
if ((fp = net_packet_open()) == NULL) if ((fp = net_packet_open()) == NULL)
return -1; return -1;
if (generic_record_read(fp, packet_show_line, f, AF_PACKET)) if (generic_record_read(fp, packet_show_line, f, AF_PACKET))
return -1; rc = -1;
return 0; fclose(fp);
return rc;
} }
static int netlink_show_one(struct filter *f, static int netlink_show_one(struct filter *f,
...@@ -3215,6 +3219,7 @@ static int netlink_show(struct filter *f) ...@@ -3215,6 +3219,7 @@ static int netlink_show(struct filter *f)
netlink_show_one(f, prot, pid, groups, 0, 0, 0, rq, wq, sk, cb); netlink_show_one(f, prot, pid, groups, 0, 0, 0, rq, wq, sk, cb);
} }
fclose(fp);
return 0; return 0;
} }
......
...@@ -67,42 +67,32 @@ int parse_size_table(int *argcp, char ***argvp, struct tc_sizespec *sp) ...@@ -67,42 +67,32 @@ int parse_size_table(int *argcp, char ***argvp, struct tc_sizespec *sp)
NEXT_ARG(); NEXT_ARG();
if (s.mtu) if (s.mtu)
duparg("mtu", *argv); duparg("mtu", *argv);
if (get_u32(&s.mtu, *argv, 10)) { if (get_u32(&s.mtu, *argv, 10))
invarg("mtu", "invalid mtu"); invarg("mtu", "invalid mtu");
return -1;
}
} else if (matches(*argv, "mpu") == 0) { } else if (matches(*argv, "mpu") == 0) {
NEXT_ARG(); NEXT_ARG();
if (s.mpu) if (s.mpu)
duparg("mpu", *argv); duparg("mpu", *argv);
if (get_u32(&s.mpu, *argv, 10)) { if (get_u32(&s.mpu, *argv, 10))
invarg("mpu", "invalid mpu"); invarg("mpu", "invalid mpu");
return -1;
}
} else if (matches(*argv, "overhead") == 0) { } else if (matches(*argv, "overhead") == 0) {
NEXT_ARG(); NEXT_ARG();
if (s.overhead) if (s.overhead)
duparg("overhead", *argv); duparg("overhead", *argv);
if (get_integer(&s.overhead, *argv, 10)) { if (get_integer(&s.overhead, *argv, 10))
invarg("overhead", "invalid overhead"); invarg("overhead", "invalid overhead");
return -1;
}
} else if (matches(*argv, "tsize") == 0) { } else if (matches(*argv, "tsize") == 0) {
NEXT_ARG(); NEXT_ARG();
if (s.tsize) if (s.tsize)
duparg("tsize", *argv); duparg("tsize", *argv);
if (get_u32(&s.tsize, *argv, 10)) { if (get_u32(&s.tsize, *argv, 10))
invarg("tsize", "invalid table size"); invarg("tsize", "invalid table size");
return -1;
}
} else if (matches(*argv, "linklayer") == 0) { } else if (matches(*argv, "linklayer") == 0) {
NEXT_ARG(); NEXT_ARG();
if (s.linklayer != LINKLAYER_UNSPEC) if (s.linklayer != LINKLAYER_UNSPEC)
duparg("linklayer", *argv); duparg("linklayer", *argv);
if (get_linklayer(&s.linklayer, *argv)) { if (get_linklayer(&s.linklayer, *argv))
invarg("linklayer", "invalid linklayer"); invarg("linklayer", "invalid linklayer");
return -1;
}
} else } else
break; break;
argc--; argv++; argc--; argv++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment