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
1d63d8c6
Commit
1d63d8c6
authored
May 18, 2016
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into net-next
parents
25ec49be
bbe2abdf
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
2 deletions
+67
-2
include/SNAPSHOT.h
include/SNAPSHOT.h
+1
-1
include/libnetlink.h
include/libnetlink.h
+6
-0
ip/ipaddress.c
ip/ipaddress.c
+32
-1
lib/libnetlink.c
lib/libnetlink.c
+28
-0
No files found.
include/SNAPSHOT.h
View file @
1d63d8c6
static
const
char
SNAPSHOT
[]
=
"160
314
"
;
static
const
char
SNAPSHOT
[]
=
"160
518
"
;
include/libnetlink.h
View file @
1d63d8c6
...
@@ -38,6 +38,12 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
...
@@ -38,6 +38,12 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
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
));
typedef
int
(
*
req_filter_fn_t
)(
struct
nlmsghdr
*
nlh
,
int
reqlen
);
int
rtnl_wilddump_req_filter_fn
(
struct
rtnl_handle
*
rth
,
int
fam
,
int
type
,
req_filter_fn_t
fn
)
__attribute__
((
warn_unused_result
));
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
));
...
...
ip/ipaddress.c
View file @
1d63d8c6
...
@@ -1476,6 +1476,36 @@ static int ipaddr_flush(void)
...
@@ -1476,6 +1476,36 @@ static int ipaddr_flush(void)
return
1
;
return
1
;
}
}
static
int
iplink_filter_req
(
struct
nlmsghdr
*
nlh
,
int
reqlen
)
{
int
err
;
err
=
addattr32
(
nlh
,
reqlen
,
IFLA_EXT_MASK
,
RTEXT_FILTER_VF
);
if
(
err
)
return
err
;
if
(
filter
.
master
)
{
err
=
addattr32
(
nlh
,
reqlen
,
IFLA_MASTER
,
filter
.
master
);
if
(
err
)
return
err
;
}
if
(
filter
.
kind
)
{
struct
rtattr
*
linkinfo
;
linkinfo
=
addattr_nest
(
nlh
,
reqlen
,
IFLA_LINKINFO
);
err
=
addattr_l
(
nlh
,
reqlen
,
IFLA_INFO_KIND
,
filter
.
kind
,
strlen
(
filter
.
kind
));
if
(
err
)
return
err
;
addattr_nest_end
(
nlh
,
linkinfo
);
}
return
0
;
}
static
int
ipaddr_list_flush_or_save
(
int
argc
,
char
**
argv
,
int
action
)
static
int
ipaddr_list_flush_or_save
(
int
argc
,
char
**
argv
,
int
action
)
{
{
struct
nlmsg_chain
linfo
=
{
NULL
,
NULL
};
struct
nlmsg_chain
linfo
=
{
NULL
,
NULL
};
...
@@ -1638,7 +1668,8 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
...
@@ -1638,7 +1668,8 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
exit
(
0
);
exit
(
0
);
}
}
if
(
rtnl_wilddump_request
(
&
rth
,
preferred_family
,
RTM_GETLINK
)
<
0
)
{
if
(
rtnl_wilddump_req_filter_fn
(
&
rth
,
preferred_family
,
RTM_GETLINK
,
iplink_filter_req
)
<
0
)
{
perror
(
"Cannot send dump request"
);
perror
(
"Cannot send dump request"
);
exit
(
1
);
exit
(
1
);
}
}
...
...
lib/libnetlink.c
View file @
1d63d8c6
...
@@ -129,6 +129,34 @@ int rtnl_wilddump_req_filter(struct rtnl_handle *rth, int family, int type,
...
@@ -129,6 +129,34 @@ int rtnl_wilddump_req_filter(struct rtnl_handle *rth, int family, int type,
return
send
(
rth
->
fd
,
(
void
*
)
&
req
,
sizeof
(
req
),
0
);
return
send
(
rth
->
fd
,
(
void
*
)
&
req
,
sizeof
(
req
),
0
);
}
}
int
rtnl_wilddump_req_filter_fn
(
struct
rtnl_handle
*
rth
,
int
family
,
int
type
,
req_filter_fn_t
filter_fn
)
{
struct
{
struct
nlmsghdr
nlh
;
struct
ifinfomsg
ifm
;
char
buf
[
1024
];
}
req
;
int
err
;
if
(
!
filter_fn
)
return
-
EINVAL
;
memset
(
&
req
,
0
,
sizeof
(
req
));
req
.
nlh
.
nlmsg_len
=
NLMSG_LENGTH
(
sizeof
(
struct
ifinfomsg
));
req
.
nlh
.
nlmsg_type
=
type
;
req
.
nlh
.
nlmsg_flags
=
NLM_F_DUMP
|
NLM_F_REQUEST
;
req
.
nlh
.
nlmsg_pid
=
0
;
req
.
nlh
.
nlmsg_seq
=
rth
->
dump
=
++
rth
->
seq
;
req
.
ifm
.
ifi_family
=
family
;
err
=
filter_fn
(
&
req
.
nlh
,
sizeof
(
req
));
if
(
err
)
return
err
;
return
send
(
rth
->
fd
,
(
void
*
)
&
req
,
sizeof
(
req
),
0
);
}
int
rtnl_send
(
struct
rtnl_handle
*
rth
,
const
void
*
buf
,
int
len
)
int
rtnl_send
(
struct
rtnl_handle
*
rth
,
const
void
*
buf
,
int
len
)
{
{
return
send
(
rth
->
fd
,
buf
,
len
,
0
);
return
send
(
rth
->
fd
,
buf
,
len
,
0
);
...
...
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