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
60a6aa5a
Commit
60a6aa5a
authored
May 20, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Teach ip monitor to also show info about cached (= cloned) routes
parent
1d63d8c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
7 deletions
+23
-7
ip/ipmonitor.c
ip/ipmonitor.c
+7
-4
ip/iproute.c
ip/iproute.c
+6
-2
lib/utils.c
lib/utils.c
+10
-1
No files found.
ip/ipmonitor.c
View file @
60a6aa5a
...
...
@@ -62,22 +62,25 @@ static int accept_msg(const struct sockaddr_nl *who,
if
(
n
->
nlmsg_type
==
RTM_NEWROUTE
||
n
->
nlmsg_type
==
RTM_DELROUTE
)
{
struct
rtmsg
*
r
=
NLMSG_DATA
(
n
);
int
len
=
n
->
nlmsg_len
-
NLMSG_LENGTH
(
sizeof
(
*
r
));
bool
rtcloned
=
r
->
rtm_flags
&
RTM_F_CLONED
;
if
(
len
<
0
)
{
fprintf
(
stderr
,
"BUG: wrong nlmsg len %d
\n
"
,
len
);
return
-
1
;
}
if
(
r
->
rtm_flags
&
RTM_F_CLONED
)
return
0
;
//
if (r->rtm_flags & RTM_F_CLONED)
//
return 0;
if
(
r
->
rtm_family
==
RTNL_FAMILY_IPMR
||
r
->
rtm_family
==
RTNL_FAMILY_IP6MR
)
{
print_headers
(
fp
,
"[MROUTE]"
,
ctrl
);
print_headers
(
fp
,
rtcloned
?
"[MRCACHE]"
:
"[MROUTE]"
,
ctrl
);
print_mroute
(
who
,
n
,
arg
);
return
0
;
}
else
{
print_headers
(
fp
,
"[ROUTE]"
,
ctrl
);
//fprintf(fp, "\n\nRRR\n");
print_headers
(
fp
,
rtcloned
?
"[RTCAH]"
:
"[ROUTE]"
,
ctrl
);
//fprintf(fp, "X\n");
print_route
(
who
,
n
,
arg
);
return
0
;
}
...
...
ip/iproute.c
View file @
60a6aa5a
...
...
@@ -155,8 +155,9 @@ static int filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len)
if
(
r
->
rtm_family
==
AF_INET6
&&
table
!=
RT_TABLE_MAIN
)
ip6_multiple_tables
=
1
;
if
(
filter
.
cloned
==
!
(
r
->
rtm_flags
&
RTM_F_CLONED
))
return
0
;
// kirr: show cached routes
//if (filter.cloned == !(r->rtm_flags&RTM_F_CLONED))
// return 0;
if
(
r
->
rtm_family
==
AF_INET6
&&
!
ip6_multiple_tables
)
{
if
(
filter
.
tb
)
{
...
...
@@ -329,6 +330,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
n
->
nlmsg_len
,
n
->
nlmsg_type
,
n
->
nlmsg_flags
);
return
0
;
}
//fprintf(fp, "flushb: %p\n", filter.flushb);
if
(
filter
.
flushb
&&
n
->
nlmsg_type
!=
RTM_NEWROUTE
)
return
0
;
len
-=
NLMSG_LENGTH
(
sizeof
(
*
r
));
...
...
@@ -342,8 +344,10 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
parse_rtattr
(
tb
,
RTA_MAX
,
RTM_RTA
(
r
),
len
);
table
=
rtm_get_table
(
r
,
tb
);
//fprintf(fp, "R: before filter_nlmsg\n");
if
(
!
filter_nlmsg
(
n
,
tb
,
host_len
))
return
0
;
//fprintf(fp, "R: after filter_nlmsg\n");
if
(
filter
.
flushb
)
{
struct
nlmsghdr
*
fn
;
...
...
lib/utils.c
View file @
60a6aa5a
...
...
@@ -1031,12 +1031,21 @@ int inet_get_addr(const char *src, __u32 *dst, struct in6_addr *dst6)
void
print_nlmsg_timestamp
(
FILE
*
fp
,
const
struct
nlmsghdr
*
n
)
{
char
*
tstr
;
//
char *tstr;
time_t
secs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
0
];
long
usecs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
1
];
#if 0
/* verbose timestamp on separate line */
tstr = asctime(localtime(&secs));
tstr[strlen(tstr)-1] = 0;
fprintf(fp, "Timestamp: %s %lu us\n", tstr, usecs);
#else
/* short timestamp on the same line as prefix */
char
tshort
[
40
];
strftime
(
tshort
,
sizeof
(
tshort
),
"%Y-%m-%dT%H:%M:%S"
,
localtime
(
&
secs
));
fprintf
(
fp
,
"[%s.%06ld] "
,
tshort
,
usecs
);
#endif
}
static
int
on_netns
(
char
*
nsname
,
void
*
arg
)
...
...
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