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
f975059a
Commit
f975059a
authored
Jun 25, 2015
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into net-next
parents
586b3978
30383b07
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
150 additions
and
74 deletions
+150
-74
Makefile
Makefile
+2
-0
configure
configure
+16
-0
misc/ss.c
misc/ss.c
+41
-49
tc/tc_util.c
tc/tc_util.c
+3
-2
testsuite/Makefile
testsuite/Makefile
+4
-0
testsuite/lib/generic.sh
testsuite/lib/generic.sh
+58
-22
testsuite/tests/ip/link/new_link.t
testsuite/tests/ip/link/new_link.t
+4
-0
testsuite/tests/ip/route/add_default_route.t
testsuite/tests/ip/route/add_default_route.t
+22
-1
No files found.
Makefile
View file @
f975059a
...
...
@@ -32,6 +32,8 @@ ADDLIB+=mpls_ntop.o mpls_pton.o
CC
=
gcc
HOSTCC
=
gcc
DEFINES
+=
-D_GNU_SOURCE
# Turn on transparent support for LFS
DEFINES
+=
-D_FILE_OFFSET_BITS
=
64
-D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE
CCOPTS
=
-O2
WFLAGS
:=
-Wall
-Wstrict-prototypes
-Wmissing-prototypes
WFLAGS
+=
-Wmissing-declarations
-Wold-style-definition
-Wformat
=
2
...
...
configure
View file @
f975059a
...
...
@@ -284,6 +284,17 @@ check_selinux()
fi
}
check_mnl
()
{
if
${
PKG_CONFIG
}
libmnl
--exists
then
echo
"HAVE_MNL:=y"
>>
Config
echo
-n
"yes"
else
echo
-n
"no"
fi
}
echo
"# Generated config based on"
$INCLUDE
>
Config
check_toolchain
...
...
@@ -313,5 +324,10 @@ check_selinux
echo
-n
"ELF support: "
check_elf
echo
-n
"libmnl support: "
check_mnl
echo
" (required by tipc)"
echo
-e
"
\n
Docs"
check_docs
echo
""
misc/ss.c
View file @
f975059a
...
...
@@ -755,7 +755,7 @@ struct tcpstat
int
timer
;
int
timeout
;
int
probes
;
char
*
cong_alg
;
char
cong_alg
[
16
]
;
double
rto
,
ato
,
rtt
,
rttvar
;
int
qack
,
cwnd
,
ssthresh
,
backoff
;
double
send_bps
;
...
...
@@ -860,8 +860,7 @@ static const char *print_ms_timer(int timeout)
return
buf
;
}
struct
scache
{
struct
scache
{
struct
scache
*
next
;
int
port
;
char
*
name
;
...
...
@@ -951,11 +950,15 @@ static const char *__resolve_service(int port)
return
NULL
;
}
#define SCACHE_BUCKETS 1024
static
struct
scache
*
cache_htab
[
SCACHE_BUCKETS
];
static
const
char
*
resolve_service
(
int
port
)
{
static
char
buf
[
128
];
static
struct
scache
cache
[
256
];
struct
scache
*
c
;
const
char
*
res
;
int
hash
;
if
(
port
==
0
)
{
buf
[
0
]
=
'*'
;
...
...
@@ -963,45 +966,35 @@ static const char *resolve_service(int port)
return
buf
;
}
if
(
resolve_services
)
{
if
(
dg_proto
==
RAW_PROTO
)
{
return
inet_proto_n2a
(
port
,
buf
,
sizeof
(
buf
));
}
else
{
struct
scache
*
c
;
const
char
*
res
;
int
hash
=
(
port
^
(((
unsigned
long
)
dg_proto
)
>>
2
))
&
255
;
for
(
c
=
&
cache
[
hash
];
c
;
c
=
c
->
next
)
{
if
(
c
->
port
==
port
&&
c
->
proto
==
dg_proto
)
{
if
(
c
->
name
)
return
c
->
name
;
goto
do_numeric
;
}
}
if
(
!
resolve_services
)
goto
do_numeric
;
if
((
res
=
__resolve_service
(
port
))
!=
NULL
)
{
if
((
c
=
malloc
(
sizeof
(
*
c
)))
==
NULL
)
goto
do_numeric
;
}
else
{
c
=
&
cache
[
hash
];
if
(
c
->
name
)
free
(
c
->
name
);
}
c
->
port
=
port
;
c
->
name
=
NULL
;
c
->
proto
=
dg_proto
;
if
(
res
)
{
c
->
name
=
strdup
(
res
);
c
->
next
=
cache
[
hash
].
next
;
cache
[
hash
].
next
=
c
;
}
if
(
c
->
name
)
return
c
->
name
;
}
if
(
dg_proto
==
RAW_PROTO
)
return
inet_proto_n2a
(
port
,
buf
,
sizeof
(
buf
));
hash
=
(
port
^
(((
unsigned
long
)
dg_proto
)
>>
2
))
%
SCACHE_BUCKETS
;
for
(
c
=
cache_htab
[
hash
];
c
;
c
=
c
->
next
)
{
if
(
c
->
port
==
port
&&
c
->
proto
==
dg_proto
)
goto
do_cache
;
}
do_numeric:
c
=
malloc
(
sizeof
(
*
c
));
if
(
!
c
)
goto
do_numeric
;
res
=
__resolve_service
(
port
);
c
->
port
=
port
;
c
->
name
=
res
?
strdup
(
res
)
:
NULL
;
c
->
proto
=
dg_proto
;
c
->
next
=
cache_htab
[
hash
];
cache_htab
[
hash
]
=
c
;
do_cache:
if
(
c
->
name
)
return
c
->
name
;
do_numeric:
sprintf
(
buf
,
"%u"
,
port
);
return
buf
;
}
...
...
@@ -1666,7 +1659,7 @@ static void tcp_stats_print(struct tcpstat *s)
printf
(
" ecnseen"
);
if
(
s
->
has_fastopen_opt
)
printf
(
" fastopen"
);
if
(
s
->
cong_alg
)
if
(
s
->
cong_alg
[
0
]
)
printf
(
" %s"
,
s
->
cong_alg
);
if
(
s
->
has_wscale_opt
)
printf
(
" wscale:%d,%d"
,
s
->
snd_wscale
,
s
->
rcv_wscale
);
...
...
@@ -1913,11 +1906,10 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r,
s
.
has_fastopen_opt
=
TCPI_HAS_OPT
(
info
,
TCPI_OPT_SYN_DATA
);
}
if
(
tb
[
INET_DIAG_CONG
])
{
const
char
*
cong_attr
=
rta_getattr_str
(
tb
[
INET_DIAG_CONG
]);
s
.
cong_alg
=
malloc
(
strlen
(
cong_attr
+
1
));
strcpy
(
s
.
cong_alg
,
cong_attr
);
}
if
(
tb
[
INET_DIAG_CONG
])
strncpy
(
s
.
cong_alg
,
rta_getattr_str
(
tb
[
INET_DIAG_CONG
]),
sizeof
(
s
.
cong_alg
)
-
1
);
if
(
TCPI_HAS_OPT
(
info
,
TCPI_OPT_WSCALE
))
{
s
.
has_wscale_opt
=
true
;
...
...
@@ -1993,8 +1985,6 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r,
tcp_stats_print
(
&
s
);
if
(
s
.
dctcp
)
free
(
s
.
dctcp
);
if
(
s
.
cong_alg
)
free
(
s
.
cong_alg
);
}
}
...
...
@@ -2218,6 +2208,8 @@ static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
return
-
1
;
rth
.
dump
=
MAGIC_SEQ
;
rth
.
dump_fp
=
dump_fp
;
if
(
preferred_family
==
PF_INET6
)
family
=
PF_INET6
;
again:
if
((
err
=
sockdiag_send
(
family
,
rth
.
fd
,
protocol
,
f
)))
...
...
@@ -2230,7 +2222,7 @@ again:
}
goto
Exit
;
}
if
(
family
==
PF_INET
)
{
if
(
family
==
PF_INET
&&
preferred_family
!=
PF_INET
)
{
family
=
PF_INET6
;
goto
again
;
}
...
...
tc/tc_util.c
View file @
f975059a
...
...
@@ -250,18 +250,19 @@ void print_rate(char *buf, int len, __u64 rate)
extern
int
use_iec
;
unsigned
long
kilo
=
use_iec
?
1024
:
1000
;
const
char
*
str
=
use_iec
?
"i"
:
""
;
int
i
=
0
;
static
char
*
units
[
5
]
=
{
""
,
"K"
,
"M"
,
"G"
,
"T"
};
int
i
;
rate
<<=
3
;
/* bytes/sec -> bits/sec */
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
units
);
i
++
)
{
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
units
)
-
1
;
i
++
)
{
if
(
rate
<
kilo
)
break
;
if
(((
rate
%
kilo
)
!=
0
)
&&
rate
<
1000
*
kilo
)
break
;
rate
/=
kilo
;
}
snprintf
(
buf
,
len
,
"%.0f%s%sbit"
,
(
double
)
rate
,
units
[
i
],
str
);
}
...
...
testsuite/Makefile
View file @
f975059a
...
...
@@ -52,6 +52,9 @@ endif
@
for
i
in
$(IPVERS)
;
do
\
o
=
`
echo
$$
i |
sed
-e
's/iproute2\///'
`
;
\
echo
-n
"Running
$@
[
$$
o/
`
uname
-r
`
]: "
;
\
TMP_ERR
=
`
mktemp
/tmp/tc_testsuite.XXXXXX
`
;
\
TMP_OUT
=
`
mktemp
/tmp/tc_testsuite.XXXXXX
`
;
\
STD_ERR
=
"
$$
TMP_ERR"
STD_OUT
=
"
$$
TMP_OUT"
\
TC
=
"
$$
i/tc/tc"
IP
=
"
$$
i/ip/ip"
DEV
=
"
$(DEV)
"
IPVER
=
"
$@
"
SNAME
=
"
$$
i"
\
ERRF
=
"
$(RESULTS_DIR)
/
$@
.
$$
o.err"
$(KENV)
$(PREFIX)
tests/
$@
>
$(RESULTS_DIR)
/
$@
.
$$
o.out
;
\
if
[
"
$$
?"
=
"127"
]
;
then
\
...
...
@@ -61,5 +64,6 @@ endif
else
\
echo
"PASS"
;
\
fi
;
\
rm
"
$$
TMP_ERR"
"
$$
TMP_OUT"
;
\
dmesg
>
$(RESULTS_DIR)
/
$@
.
$$
o.dmesg
;
\
done
testsuite/lib/generic.sh
View file @
f975059a
...
...
@@ -30,57 +30,49 @@ ts_tc()
{
SCRIPT
=
$1
;
shift
DESC
=
$1
;
shift
TMP_ERR
=
`
mktemp
/tmp/tc_testsuite.XXXXXX
`
||
exit
TMP_OUT
=
`
mktemp
/tmp/tc_testsuite.XXXXXX
`
||
exit
$TC
$@
2>
$
TMP_ERR
>
$TMP
_OUT
$TC
$@
2>
$
STD_ERR
>
$STD
_OUT
if
[
-s
$
TMP
_ERR
]
;
then
if
[
-s
$
STD
_ERR
]
;
then
ts_err
"
${
SCRIPT
}
:
${
DESC
}
failed:"
ts_err
"command:
$TC
$@
"
ts_err
"stderr output:"
ts_err_cat
$
TMP
_ERR
if
[
-s
$
TMP
_OUT
]
;
then
ts_err_cat
$
STD
_ERR
if
[
-s
$
STD
_OUT
]
;
then
ts_err
"stdout output:"
ts_err_cat
$
TMP
_OUT
ts_err_cat
$
STD
_OUT
fi
elif
[
-s
$
TMP
_OUT
]
;
then
elif
[
-s
$
STD
_OUT
]
;
then
echo
"
${
SCRIPT
}
:
${
DESC
}
succeeded with output:"
cat
$
TMP
_OUT
cat
$
STD
_OUT
else
echo
"
${
SCRIPT
}
:
${
DESC
}
succeeded"
fi
rm
$TMP_ERR
$TMP_OUT
}
ts_ip
()
{
SCRIPT
=
$1
;
shift
DESC
=
$1
;
shift
TMP_ERR
=
`
mktemp
/tmp/tc_testsuite.XXXXXX
`
||
exit
TMP_OUT
=
`
mktemp
/tmp/tc_testsuite.XXXXXX
`
||
exit
$IP
$@
2>
$
TMP_ERR
>
$TMP
_OUT
$IP
$@
2>
$
STD_ERR
>
$STD
_OUT
RET
=
$?
if
[
-s
$
TMP
_ERR
]
||
[
"
$RET
"
!=
"0"
]
;
then
if
[
-s
$
STD
_ERR
]
||
[
"
$RET
"
!=
"0"
]
;
then
ts_err
"
${
SCRIPT
}
:
${
DESC
}
failed:"
ts_err
"command:
$IP
$@
"
ts_err
"stderr output:"
ts_err_cat
$
TMP
_ERR
if
[
-s
$
TMP
_OUT
]
;
then
ts_err_cat
$
STD
_ERR
if
[
-s
$
STD
_OUT
]
;
then
ts_err
"stdout output:"
ts_err_cat
$
TMP
_OUT
ts_err_cat
$
STD
_OUT
fi
elif
[
-s
$
TMP
_OUT
]
;
then
elif
[
-s
$
STD
_OUT
]
;
then
echo
"
${
SCRIPT
}
:
${
DESC
}
succeeded with output:"
cat
$
TMP
_OUT
cat
$
STD
_OUT
else
echo
"
${
SCRIPT
}
:
${
DESC
}
succeeded"
fi
rm
$TMP_ERR
$TMP_OUT
}
ts_qdisc_available
()
...
...
@@ -97,3 +89,47 @@ rand_dev()
{
echo
"dev-
$(
tr
-dc
"[:alpha:]"
< /dev/urandom |
head
-c
6
)
"
}
pr_failed
()
{
echo
" [FAILED]"
ts_err
"matching failed"
}
pr_success
()
{
echo
" [SUCCESS]"
}
test_on
()
{
echo
-n
"test on:
\"
$1
\"
"
if
cat
"
$STD_OUT
"
|
grep
-qE
"
$1
"
then
pr_success
else
pr_failed
fi
}
test_on_not
()
{
echo
-n
"test on:
\"
$1
\"
"
if
cat
"
$STD_OUT
"
|
grep
-vqE
"
$1
"
then
pr_success
else
pr_failed
fi
}
test_lines_count
()
{
echo
-n
"test on lines count (
$1
): "
if
cat
"
$STD_OUT
"
|
wc
-l
|
grep
-q
"
$1
"
then
pr_success
else
pr_failed
fi
}
testsuite/tests/ip/link/new_link.t
View file @
f975059a
...
...
@@ -7,5 +7,9 @@ ts_log "[Testing add/del virtual links]"
NEW_DEV
=
"
$(rand_dev)
"
ts_ip
"
$0
"
"
Add
$NEW_DEV
dummy interface
"
link
add
dev
$NEW_DEV
type
dummy
ts_ip
"
$0
"
"
Show
$NEW_DEV
dummy interface
"
link
show
dev
$NEW_DEV
test_on
"
$NEW_DEV
"
test_lines_count
2
ts_ip
"
$0
"
"
Del
$NEW_DEV
dummy interface
"
link
del
dev
$NEW_DEV
testsuite/tests/ip/route/add_default_route.t
View file @
f975059a
...
...
@@ -8,5 +8,26 @@ DEV=dummy0
ts_ip
"
$0
"
"
Add new interface
$DEV
"
link
add
$DEV
type
dummy
ts_ip
"
$0
"
"
Set
$DEV
into UP state
"
link
set
up
dev
$DEV
ts_ip
"
$0
"
"
Add 1.1.1.1/24 addr on
$DEV
"
addr
add
1.1.1.1
/
24
dev
$DEV
ts_ip
"
$0
"
"
Add default route via 1.1.1.1
"
route
add
default
via
1.1.1.1
ts_ip
"
$0
"
"
Add default route via 1.1.1.2
"
route
add
default
via
1.1.1.2
ts_ip
"
$0
"
"
Show IPv4 default route
"
-
4
route
show
default
test_on
"
default via 1.1.1.2 dev
$DEV
"
test_lines_count
1
ts_ip
"
$0
"
"
Add another IPv4 route dst 2.2.2.0/24
"
-
4
route
add
2.2.2.0
/
24
dev
$DEV
ts_ip
"
$0
"
"
Show IPv4 default route
"
-
4
route
show
default
test_on
"
default via 1.1.1.2 dev
$DEV
"
test_lines_count
1
ts_ip
"
$0
"
"
Add dead:beef::1/64 addr on
$DEV
"
-
6
addr
add
dead:beef::1
/
64
dev
$DEV
ts_ip
"
$0
"
"
Add default route via dead:beef::2
"
route
add
default
via
dead:beef::2
ts_ip
"
$0
"
"
Show IPv6 default route
"
-
6
route
show
default
test_on
"
default via dead:beef::2 dev
$DEV
"
test_lines_count
1
ts_ip
"
$0
"
"
Add another IPv6 route dst cafe:babe::/64
"
-
6
route
add
cafe:babe::
/
64
dev
$DEV
ts_ip
"
$0
"
"
Show IPv6 default route
"
-
6
route
show
default
test_on
"
default via dead:beef::2 dev
$DEV
"
test_lines_count
1
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