Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
090d565c
Unverified
Commit
090d565c
authored
Sep 30, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
netns_ifaddrs: handle IFLA_STATS{64} correctly
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
76f21f71
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
4 deletions
+29
-4
configure.ac
configure.ac
+3
-0
netns_ifaddrs.c
src/include/netns_ifaddrs.c
+14
-2
netns_ifaddrs.h
src/include/netns_ifaddrs.h
+5
-2
macro.h
src/lxc/macro.h
+7
-0
No files found.
configure.ac
View file @
090d565c
...
@@ -668,6 +668,9 @@ AC_CHECK_FUNCS([strlcat],
...
@@ -668,6 +668,9 @@ AC_CHECK_FUNCS([strlcat],
AC_DEFINE(HAVE_STRLCAT,1,[Have strlcat]),
AC_DEFINE(HAVE_STRLCAT,1,[Have strlcat]),
AM_CONDITIONAL(HAVE_STRLCAT, false))
AM_CONDITIONAL(HAVE_STRLCAT, false))
# HAVE_STRUCT_RTNL_LINK_STATS64={0,1}
AC_CHECK_TYPES([struct rtnl_link_stats64], [], [], [[#include <linux/if_link.h>]])
# Check for some libraries
# Check for some libraries
AX_PTHREAD
AX_PTHREAD
AC_SEARCH_LIBS(clock_gettime, [rt])
AC_SEARCH_LIBS(clock_gettime, [rt])
...
...
src/include/netns_ifaddrs.c
View file @
090d565c
...
@@ -177,7 +177,11 @@ static int nl_msg_to_ifaddr(void *pctx, bool *netnsid_aware, struct nlmsghdr *h)
...
@@ -177,7 +177,11 @@ static int nl_msg_to_ifaddr(void *pctx, bool *netnsid_aware, struct nlmsghdr *h)
#pragma GCC diagnostic ignored "-Wcast-align"
#pragma GCC diagnostic ignored "-Wcast-align"
for
(
rta
=
__NLMSG_RTA
(
h
,
sizeof
(
*
ifi
));
__NLMSG_RTAOK
(
rta
,
h
);
for
(
rta
=
__NLMSG_RTA
(
h
,
sizeof
(
*
ifi
));
__NLMSG_RTAOK
(
rta
,
h
);
rta
=
__RTA_NEXT
(
rta
))
{
rta
=
__RTA_NEXT
(
rta
))
{
#if HAVE_STRUCT_RTNL_LINK_STATS64
if
(
rta
->
rta_type
!=
IFLA_STATS64
)
#else
if
(
rta
->
rta_type
!=
IFLA_STATS
)
if
(
rta
->
rta_type
!=
IFLA_STATS
)
#endif
continue
;
continue
;
stats_len
=
__RTA_DATALEN
(
rta
);
stats_len
=
__RTA_DATALEN
(
rta
);
...
@@ -226,11 +230,19 @@ static int nl_msg_to_ifaddr(void *pctx, bool *netnsid_aware, struct nlmsghdr *h)
...
@@ -226,11 +230,19 @@ static int nl_msg_to_ifaddr(void *pctx, bool *netnsid_aware, struct nlmsghdr *h)
__RTA_DATA
(
rta
),
__RTA_DATALEN
(
rta
),
__RTA_DATA
(
rta
),
__RTA_DATALEN
(
rta
),
ifi
->
ifi_index
,
ifi
->
ifi_type
);
ifi
->
ifi_index
,
ifi
->
ifi_type
);
break
;
break
;
#if HAVE_STRUCT_RTNL_LINK_STATS64
case
IFLA_STATS64
:
ifs
->
ifa
.
ifa_stats_type
=
IFLA_STATS64
;
memcpy
(
&
ifs
->
ifa
.
ifa_stats64
,
__RTA_DATA
(
rta
),
__RTA_DATALEN
(
rta
));
break
;
#else
case
IFLA_STATS
:
case
IFLA_STATS
:
ifs
->
ifa
.
ifa_
data
=
(
void
*
)(
ifs
+
1
)
;
ifs
->
ifa
.
ifa_
stats_type
=
IFLA_STATS
;
memcpy
(
ifs
->
ifa
.
ifa_data
,
__RTA_DATA
(
rta
),
memcpy
(
&
ifs
->
ifa
.
ifa_stats32
,
__RTA_DATA
(
rta
),
__RTA_DATALEN
(
rta
));
__RTA_DATALEN
(
rta
));
break
;
break
;
#endif
case
IFLA_MTU
:
case
IFLA_MTU
:
memcpy
(
&
ifs
->
ifa
.
ifa_mtu
,
__RTA_DATA
(
rta
),
memcpy
(
&
ifs
->
ifa
.
ifa_mtu
,
__RTA_DATA
(
rta
),
sizeof
(
int
));
sizeof
(
int
));
...
...
src/include/netns_ifaddrs.h
View file @
090d565c
...
@@ -6,6 +6,7 @@ extern "C" {
...
@@ -6,6 +6,7 @@ extern "C" {
#endif
#endif
#include <features.h>
#include <features.h>
#include <linux/if_link.h>
#include <linux/types.h>
#include <linux/types.h>
#include <netinet/in.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdbool.h>
...
@@ -37,8 +38,10 @@ struct netns_ifaddrs {
...
@@ -37,8 +38,10 @@ struct netns_ifaddrs {
struct
sockaddr
*
ifu_dstaddr
;
struct
sockaddr
*
ifu_dstaddr
;
}
ifa_ifu
;
}
ifa_ifu
;
/* If you don't know what this is for don't touch it. */
/* These fields are not present struct ifaddrs. */
void
*
ifa_data
;
int
ifa_stats_type
;
struct
rtnl_link_stats
ifa_stats32
;
struct
rtnl_link_stats64
ifa_stats64
;
};
};
#define __ifa_broadaddr ifa_ifu.ifu_broadaddr
#define __ifa_broadaddr ifa_ifu.ifu_broadaddr
...
...
src/lxc/macro.h
View file @
090d565c
...
@@ -283,6 +283,13 @@ extern int __build_bug_on_failed;
...
@@ -283,6 +283,13 @@ extern int __build_bug_on_failed;
#define IFA_TARGET_NETNSID 10
#define IFA_TARGET_NETNSID 10
#endif
#endif
#ifndef IFLA_STATS
#define IFLA_STATS 7
#endif
#ifndef IFLA_STATS64
#define IFLA_STATS64 23
#endif
#ifndef RTM_NEWNSID
#ifndef RTM_NEWNSID
#define RTM_NEWNSID 88
#define RTM_NEWNSID 88
...
...
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