Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
iproute2
Commits
242a9f73
Commit
242a9f73
authored
Jan 13, 2015
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into net-next
parents
6ef87f9c
c3087c10
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
113 additions
and
71 deletions
+113
-71
bridge/monitor.c
bridge/monitor.c
+3
-15
include/libnetlink.h
include/libnetlink.h
+4
-0
include/namespace.h
include/namespace.h
+1
-0
include/utils.h
include/utils.h
+2
-0
ip/ip_common.h
ip/ip_common.h
+0
-1
ip/ipaddress.c
ip/ipaddress.c
+37
-7
ip/iplink.c
ip/iplink.c
+2
-1
ip/ipmonitor.c
ip/ipmonitor.c
+2
-7
ip/ipnetns.c
ip/ipnetns.c
+0
-15
ip/rtmon.c
ip/rtmon.c
+1
-1
lib/namespace.c
lib/namespace.c
+15
-0
lib/utils.c
lib/utils.c
+10
-0
misc/ss.c
misc/ss.c
+25
-19
tc/m_vlan.c
tc/m_vlan.c
+11
-5
No files found.
bridge/monitor.c
View file @
242a9f73
...
...
@@ -35,17 +35,6 @@ static void usage(void)
exit
(
-
1
);
}
static
int
show_mark
(
FILE
*
fp
,
const
struct
nlmsghdr
*
n
)
{
char
*
tstr
;
time_t
secs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
0
];
long
usecs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
1
];
tstr
=
asctime
(
localtime
(
&
secs
));
tstr
[
strlen
(
tstr
)
-
1
]
=
0
;
fprintf
(
fp
,
"Timestamp: %s %lu us
\n
"
,
tstr
,
usecs
);
return
0
;
}
static
int
accept_msg
(
const
struct
sockaddr_nl
*
who
,
struct
nlmsghdr
*
n
,
void
*
arg
)
{
...
...
@@ -74,14 +63,13 @@ static int accept_msg(const struct sockaddr_nl *who,
fprintf
(
fp
,
"[MDB]"
);
return
print_mdb
(
who
,
n
,
arg
);
case
15
:
return
show_mark
(
fp
,
n
);
case
NLMSG_TSTAMP
:
print_nlmsg_timestamp
(
fp
,
n
);
return
0
;
default:
return
0
;
}
}
int
do_monitor
(
int
argc
,
char
**
argv
)
...
...
include/libnetlink.h
View file @
242a9f73
...
...
@@ -158,5 +158,9 @@ extern int rtnl_from_file(FILE *, rtnl_filter_t handler,
#define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))
#endif
/* User defined nlmsg_type which is used mostly for logging netlink
* messages from dump file */
#define NLMSG_TSTAMP 15
#endif
/* __LIBNETLINK_H__ */
include/namespace.h
View file @
242a9f73
...
...
@@ -42,5 +42,6 @@ static int setns(int fd, int nstype)
#endif
/* HAVE_SETNS */
extern
int
netns_switch
(
char
*
netns
);
extern
int
netns_get_fd
(
const
char
*
netns
);
#endif
/* __NAMESPACE_H__ */
include/utils.h
View file @
242a9f73
...
...
@@ -148,6 +148,7 @@ static inline __u32 nl_mgrp(__u32 group)
int
print_timestamp
(
FILE
*
fp
);
void
print_nlmsg_timestamp
(
FILE
*
fp
,
const
struct
nlmsghdr
*
n
);
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
...
...
@@ -160,4 +161,5 @@ struct iplink_req;
int
iplink_parse
(
int
argc
,
char
**
argv
,
struct
iplink_req
*
req
,
char
**
name
,
char
**
type
,
char
**
link
,
char
**
dev
,
int
*
group
,
int
*
index
);
#endif
/* __UTILS_H__ */
ip/ip_common.h
View file @
242a9f73
...
...
@@ -87,7 +87,6 @@ struct link_util
struct
link_util
*
get_link_kind
(
const
char
*
kind
);
struct
link_util
*
get_link_slave_kind
(
const
char
*
slave_kind
);
int
get_netns_fd
(
const
char
*
name
);
#ifndef INFINITY_LIFE_TIME
#define INFINITY_LIFE_TIME 0xFFFFFFFFU
...
...
ip/ipaddress.c
View file @
242a9f73
...
...
@@ -255,15 +255,37 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
}
}
static
void
print_af_spec
(
FILE
*
fp
,
struct
rtattr
*
af_spec_attr
)
{
struct
rtattr
*
inet6_attr
;
struct
rtattr
*
tb
[
IFLA_INET6_MAX
+
1
];
inet6_attr
=
parse_rtattr_one_nested
(
AF_INET6
,
af_spec_attr
);
if
(
!
inet6_attr
)
return
;
parse_rtattr_nested
(
tb
,
IFLA_INET6_MAX
,
inet6_attr
);
if
(
tb
[
IFLA_INET6_ADDR_GEN_MODE
])
{
switch
(
rta_getattr_u8
(
tb
[
IFLA_INET6_ADDR_GEN_MODE
]))
{
case
IN6_ADDR_GEN_MODE_EUI64
:
fprintf
(
fp
,
"addrgenmode eui64 "
);
break
;
case
IN6_ADDR_GEN_MODE_NONE
:
fprintf
(
fp
,
"addrgenmode none "
);
break
;
}
}
}
static
void
print_vfinfo
(
FILE
*
fp
,
struct
rtattr
*
vfinfo
)
{
struct
ifla_vf_mac
*
vf_mac
;
struct
ifla_vf_vlan
*
vf_vlan
;
struct
ifla_vf_rate
*
vf_rate
;
struct
ifla_vf_tx_rate
*
vf_tx_rate
;
struct
ifla_vf_spoofchk
*
vf_spoofchk
;
struct
ifla_vf_link_state
*
vf_linkstate
;
struct
rtattr
*
vf
[
IFLA_VF_MAX
+
1
]
;
struct
rtattr
*
vf
[
IFLA_VF_MAX
+
1
]
=
{}
;
struct
rtattr
*
tmp
;
SPRINT_BUF
(
b1
);
...
...
@@ -277,7 +299,6 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
vf_mac
=
RTA_DATA
(
vf
[
IFLA_VF_MAC
]);
vf_vlan
=
RTA_DATA
(
vf
[
IFLA_VF_VLAN
]);
vf_tx_rate
=
RTA_DATA
(
vf
[
IFLA_VF_TX_RATE
]);
vf_rate
=
RTA_DATA
(
vf
[
IFLA_VF_RATE
]);
/* Check if the spoof checking vf info type is supported by
* this kernel.
...
...
@@ -313,10 +334,16 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
fprintf
(
fp
,
", qos %d"
,
vf_vlan
->
qos
);
if
(
vf_tx_rate
->
rate
)
fprintf
(
fp
,
", tx rate %d (Mbps)"
,
vf_tx_rate
->
rate
);
if
(
vf
[
IFLA_VF_RATE
])
{
struct
ifla_vf_rate
*
vf_rate
=
RTA_DATA
(
vf
[
IFLA_VF_RATE
]);
if
(
vf_rate
->
max_tx_rate
)
fprintf
(
fp
,
", max_tx_rate %dMbps"
,
vf_rate
->
max_tx_rate
);
if
(
vf_rate
->
min_tx_rate
)
fprintf
(
fp
,
", min_tx_rate %dMbps"
,
vf_rate
->
min_tx_rate
);
}
if
(
vf_spoofchk
&&
vf_spoofchk
->
setting
!=
-
1
)
{
if
(
vf_spoofchk
->
setting
)
fprintf
(
fp
,
", spoof checking on"
);
...
...
@@ -658,6 +685,9 @@ int print_linkinfo(const struct sockaddr_nl *who,
if
(
tb
[
IFLA_LINKINFO
]
&&
show_details
)
print_linktype
(
fp
,
tb
[
IFLA_LINKINFO
]);
if
(
do_link
&&
tb
[
IFLA_AF_SPEC
]
&&
show_details
)
print_af_spec
(
fp
,
tb
[
IFLA_AF_SPEC
]);
if
((
do_link
||
show_details
)
&&
tb
[
IFLA_IFALIAS
])
{
fprintf
(
fp
,
"%s alias %s"
,
_SL_
,
rta_getattr_str
(
tb
[
IFLA_IFALIAS
]));
...
...
ip/iplink.c
View file @
242a9f73
...
...
@@ -32,6 +32,7 @@
#include "rt_names.h"
#include "utils.h"
#include "ip_common.h"
#include "namespace.h"
#define IPLINK_IOCTL_COMPAT 1
#ifndef LIBDIR
...
...
@@ -440,7 +441,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
NEXT_ARG
();
if
(
netns
!=
-
1
)
duparg
(
"netns"
,
*
argv
);
if
((
netns
=
get_netns
_fd
(
*
argv
))
>=
0
)
if
((
netns
=
netns_get
_fd
(
*
argv
))
>=
0
)
addattr_l
(
&
req
->
n
,
sizeof
(
*
req
),
IFLA_NET_NS_FD
,
&
netns
,
4
);
else
if
(
get_integer
(
&
netns
,
*
argv
,
0
)
==
0
)
addattr_l
(
&
req
->
n
,
sizeof
(
*
req
),
IFLA_NET_NS_PID
,
&
netns
,
4
);
...
...
ip/ipmonitor.c
View file @
242a9f73
...
...
@@ -125,13 +125,8 @@ static int accept_msg(const struct sockaddr_nl *who,
print_netconf
(
who
,
n
,
arg
);
return
0
;
}
if
(
n
->
nlmsg_type
==
15
)
{
char
*
tstr
;
time_t
secs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
0
];
long
usecs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
1
];
tstr
=
asctime
(
localtime
(
&
secs
));
tstr
[
strlen
(
tstr
)
-
1
]
=
0
;
fprintf
(
fp
,
"Timestamp: %s %lu us
\n
"
,
tstr
,
usecs
);
if
(
n
->
nlmsg_type
==
NLMSG_TSTAMP
)
{
print_nlmsg_timestamp
(
fp
,
n
);
return
0
;
}
if
(
n
->
nlmsg_type
!=
NLMSG_ERROR
&&
n
->
nlmsg_type
!=
NLMSG_NOOP
&&
...
...
ip/ipnetns.c
View file @
242a9f73
...
...
@@ -31,21 +31,6 @@ static int usage(void)
exit
(
-
1
);
}
int
get_netns_fd
(
const
char
*
name
)
{
char
pathbuf
[
MAXPATHLEN
];
const
char
*
path
,
*
ptr
;
path
=
name
;
ptr
=
strchr
(
name
,
'/'
);
if
(
!
ptr
)
{
snprintf
(
pathbuf
,
sizeof
(
pathbuf
),
"%s/%s"
,
NETNS_RUN_DIR
,
name
);
path
=
pathbuf
;
}
return
open
(
path
,
O_RDONLY
);
}
static
int
netns_list
(
int
argc
,
char
**
argv
)
{
struct
dirent
*
entry
;
...
...
ip/rtmon.c
View file @
242a9f73
...
...
@@ -34,7 +34,7 @@ static void write_stamp(FILE *fp)
struct
nlmsghdr
*
n1
=
(
void
*
)
buf
;
struct
timeval
tv
;
n1
->
nlmsg_type
=
15
;
n1
->
nlmsg_type
=
NLMSG_TSTAMP
;
n1
->
nlmsg_flags
=
0
;
n1
->
nlmsg_seq
=
0
;
n1
->
nlmsg_pid
=
0
;
...
...
lib/namespace.c
View file @
242a9f73
...
...
@@ -84,3 +84,18 @@ int netns_switch(char *name)
bind_etc
(
name
);
return
0
;
}
int
netns_get_fd
(
const
char
*
name
)
{
char
pathbuf
[
MAXPATHLEN
];
const
char
*
path
,
*
ptr
;
path
=
name
;
ptr
=
strchr
(
name
,
'/'
);
if
(
!
ptr
)
{
snprintf
(
pathbuf
,
sizeof
(
pathbuf
),
"%s/%s"
,
NETNS_RUN_DIR
,
name
);
path
=
pathbuf
;
}
return
open
(
path
,
O_RDONLY
);
}
lib/utils.c
View file @
242a9f73
...
...
@@ -868,3 +868,13 @@ int inet_get_addr(const char *src, __u32 *dst, struct in6_addr *dst6)
else
return
inet_pton
(
AF_INET
,
src
,
dst
);
}
void
print_nlmsg_timestamp
(
FILE
*
fp
,
const
struct
nlmsghdr
*
n
)
{
char
*
tstr
;
time_t
secs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
0
];
long
usecs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
1
];
tstr
=
asctime
(
localtime
(
&
secs
));
tstr
[
strlen
(
tstr
)
-
1
]
=
0
;
fprintf
(
fp
,
"Timestamp: %s %lu us
\n
"
,
tstr
,
usecs
);
}
misc/ss.c
View file @
242a9f73
...
...
@@ -2287,12 +2287,12 @@ static int udp_show(struct filter *f)
{
FILE
*
fp
=
NULL
;
dg_proto
=
UDP_PROTO
;
if
(
!
getenv
(
"PROC_NET_UDP"
)
&&
!
getenv
(
"PROC_ROOT"
)
&&
inet_show_netlink
(
f
,
NULL
,
IPPROTO_UDP
)
==
0
)
return
0
;
dg_proto
=
UDP_PROTO
;
if
(
f
->
families
&
(
1
<<
AF_INET
))
{
if
((
fp
=
net_udp_open
())
==
NULL
)
goto
outerr
;
...
...
@@ -3223,7 +3223,13 @@ static void _usage(FILE *dest)
"
\n
"
" -D, --diag=FILE Dump raw information about TCP sockets to FILE
\n
"
" -F, --filter=FILE read filter information from FILE
\n
"
" FILTER := [ state TCP-STATE ] [ EXPRESSION ]
\n
"
" FILTER := [ state STATE-FILTER ] [ EXPRESSION ]
\n
"
" STATE-FILTER := {all|connected|synchronized|bucket|big|TCP-STATES}
\n
"
" TCP-STATES := {established|syn-sent|syn-recv|fin-wait-{1,2}|time-wait|closed|close-wait|last-ack|listen|closing}
\n
"
" connected := {established|syn-sent|syn-recv|fin-wait-{1,2}|time-wait|close-wait|last-ack|closing}
\n
"
" synchronized := {established|syn-recv|fin-wait-{1,2}|time-wait|close-wait|last-ack|closing}
\n
"
" bucket := {syn-recv|time-wait}
\n
"
" big := {established|syn-sent|fin-wait-{1,2}|closed|close-wait|last-ack|listen|closing}
\n
"
);
}
...
...
tc/m_vlan.c
View file @
242a9f73
...
...
@@ -103,20 +103,25 @@ static int parse_vlan(struct action_util *a, int *argc_p, char ***argv_p,
if
(
argc
)
{
if
(
matches
(
*
argv
,
"reclassify"
)
==
0
)
{
parm
.
action
=
TC_ACT_RECLASSIFY
;
NEXT_ARG
();
argc
--
;
argv
++
;
}
else
if
(
matches
(
*
argv
,
"pipe"
)
==
0
)
{
parm
.
action
=
TC_ACT_PIPE
;
NEXT_ARG
();
argc
--
;
argv
++
;
}
else
if
(
matches
(
*
argv
,
"drop"
)
==
0
||
matches
(
*
argv
,
"shot"
)
==
0
)
{
parm
.
action
=
TC_ACT_SHOT
;
NEXT_ARG
();
argc
--
;
argv
++
;
}
else
if
(
matches
(
*
argv
,
"continue"
)
==
0
)
{
parm
.
action
=
TC_ACT_UNSPEC
;
NEXT_ARG
();
argc
--
;
argv
++
;
}
else
if
(
matches
(
*
argv
,
"pass"
)
==
0
)
{
parm
.
action
=
TC_ACT_OK
;
NEXT_ARG
();
argc
--
;
argv
++
;
}
}
...
...
@@ -198,6 +203,7 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg)
}
break
;
}
fprintf
(
f
,
" %s"
,
action_n2a
(
parm
->
action
,
b1
,
sizeof
(
b1
)));
fprintf
(
f
,
"
\n\t
index %d ref %d bind %d"
,
parm
->
index
,
parm
->
refcnt
,
parm
->
bindcnt
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment