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
93531fac
Commit
93531fac
authored
Apr 13, 2015
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into net-next
parents
6256f8c9
672acc72
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
34 deletions
+56
-34
configure
configure
+0
-19
include/SNAPSHOT.h
include/SNAPSHOT.h
+1
-1
ip/Makefile
ip/Makefile
+0
-4
ip/ipnetns.c
ip/ipnetns.c
+55
-10
No files found.
configure
View file @
93531fac
...
...
@@ -218,23 +218,6 @@ EOF
rm
-f
$TMPDIR
/setnstest.c
$TMPDIR
/setnstest
}
check_netnsid
()
{
cat
>
$TMPDIR
/netnsid.c
<<
EOF
#include <linux/rtnetlink.h>
int test_def = RTM_GETNSID;
EOF
$CC
-I
$INCLUDE
-c
$TMPDIR
/netnsid.c
>
/dev/null 2>&1
if
[
$?
-eq
0
]
then
echo
"IP_CONFIG_NETNSID:=y"
>>
Config
echo
"yes"
else
echo
"no"
fi
rm
-f
$TMPDIR
/netnsid.c
$TMPDIR
/netnsid.o
}
check_ipset
()
{
cat
>
$TMPDIR
/ipsettest.c
<<
EOF
...
...
@@ -323,8 +306,6 @@ check_ipt_lib_dir
echo
-n
"libc has setns: "
check_setns
echo
-n
"netns has peer id suport: "
check_netnsid
echo
-n
"SELinux support: "
check_selinux
...
...
include/SNAPSHOT.h
View file @
93531fac
static
const
char
SNAPSHOT
[]
=
"150
210
"
;
static
const
char
SNAPSHOT
[]
=
"150
413
"
;
ip/Makefile
View file @
93531fac
...
...
@@ -16,10 +16,6 @@ ifeq ($(IP_CONFIG_SETNS),y)
CFLAGS
+=
-DHAVE_SETNS
endif
ifeq
($(IP_CONFIG_NETNSID),y)
CFLAGS
+=
-DHAVE_NETNSID
endif
ALLOBJ
=
$(IPOBJ)
$(RTMONOBJ)
SCRIPTS
=
ifcfg rtpr routel routef
TARGETS
=
ip rtmon
...
...
ip/ipnetns.c
View file @
93531fac
...
...
@@ -34,7 +34,56 @@ static int usage(void)
exit
(
-
1
);
}
#ifdef HAVE_NETNSID
static
int
have_rtnl_getnsid
=
-
1
;
static
int
ipnetns_accept_msg
(
const
struct
sockaddr_nl
*
who
,
struct
nlmsghdr
*
n
,
void
*
arg
)
{
struct
nlmsgerr
*
err
=
(
struct
nlmsgerr
*
)
NLMSG_DATA
(
n
);
if
(
n
->
nlmsg_type
==
NLMSG_ERROR
&&
(
err
->
error
==
-
EOPNOTSUPP
||
err
->
error
==
-
EINVAL
))
have_rtnl_getnsid
=
0
;
else
have_rtnl_getnsid
=
1
;
return
-
1
;
}
static
int
ipnetns_have_nsid
(
void
)
{
struct
{
struct
nlmsghdr
n
;
struct
rtgenmsg
g
;
char
buf
[
1024
];
}
req
;
int
fd
;
if
(
have_rtnl_getnsid
<
0
)
{
memset
(
&
req
,
0
,
sizeof
(
req
));
req
.
n
.
nlmsg_len
=
NLMSG_LENGTH
(
sizeof
(
struct
rtgenmsg
));
req
.
n
.
nlmsg_flags
=
NLM_F_REQUEST
;
req
.
n
.
nlmsg_type
=
RTM_GETNSID
;
req
.
g
.
rtgen_family
=
AF_UNSPEC
;
fd
=
open
(
"/proc/self/ns/net"
,
O_RDONLY
);
if
(
fd
<
0
)
{
perror
(
"open(
\"
/proc/self/ns/net
\"
)"
);
exit
(
1
);
}
addattr32
(
&
req
.
n
,
1024
,
NETNSA_FD
,
fd
);
if
(
rtnl_send
(
&
rth
,
&
req
.
n
,
req
.
n
.
nlmsg_len
)
<
0
)
{
perror
(
"request send failed"
);
exit
(
1
);
}
rtnl_listen
(
&
rth
,
ipnetns_accept_msg
,
NULL
);
close
(
fd
);
}
return
have_rtnl_getnsid
;
}
static
int
get_netnsid_from_name
(
const
char
*
name
)
{
struct
{
...
...
@@ -79,12 +128,6 @@ static int get_netnsid_from_name(const char *name)
return
-
1
;
}
#else
static
int
get_netnsid_from_name
(
const
char
*
name
)
{
return
-
1
;
}
#endif
/* HAVE_NETNSID */
static
int
netns_list
(
int
argc
,
char
**
argv
)
{
...
...
@@ -102,9 +145,11 @@ static int netns_list(int argc, char **argv)
if
(
strcmp
(
entry
->
d_name
,
".."
)
==
0
)
continue
;
printf
(
"%s"
,
entry
->
d_name
);
if
(
ipnetns_have_nsid
())
{
id
=
get_netnsid_from_name
(
entry
->
d_name
);
if
(
id
>=
0
)
printf
(
" (id: %d)"
,
id
);
}
printf
(
"
\n
"
);
}
closedir
(
dir
);
...
...
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