From 742f8788211d2a861a0214e76449390b89ba55c2 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Fri, 13 Apr 2018 17:11:56 +0200 Subject: [PATCH] rtnl: remove dependency on config.h. Change the rtnl_get_ts_label() function to accept the name of the master interface and the buffer for the slave interface directly instead of the struct interface from config.h. Also, rename the function to rtnl_get_ts_device(). Signed-off-by: Miroslav Lichvar --- clock.c | 2 +- nsm.c | 2 +- rtnl.c | 10 +++++----- rtnl.h | 13 +++++++------ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/clock.c b/clock.c index 9ffb43e..afee960 100644 --- a/clock.c +++ b/clock.c @@ -948,7 +948,7 @@ struct clock *clock_create(enum clock_type type, struct config *config, c->timestamping = timestamping; required_modes = clock_required_modes(c); STAILQ_FOREACH(iface, &config->interfaces, list) { - rtnl_get_ts_label(iface); + rtnl_get_ts_device(iface->name, iface->ts_label); ensure_ts_label(iface); sk_get_ts_info(iface->ts_label, &iface->ts_info); if (iface->ts_info.valid && diff --git a/nsm.c b/nsm.c index cefea5d..fc10a60 100644 --- a/nsm.c +++ b/nsm.c @@ -267,7 +267,7 @@ static int nsm_open(struct nsm *nsm, struct config *cfg) int count = 0; STAILQ_FOREACH(iface, &cfg->interfaces, list) { - rtnl_get_ts_label(iface); + rtnl_get_ts_device(iface->name, iface->ts_label); if (iface->ts_label[0] == '\0') { strncpy(iface->ts_label, iface->name, MAX_IFNAME_SIZE); } diff --git a/rtnl.c b/rtnl.c index cea936b..f9a572b 100644 --- a/rtnl.c +++ b/rtnl.c @@ -43,13 +43,13 @@ int rtnl_close(int fd) return close(fd); } -static void rtnl_get_ts_label_callback(void *ctx, int linkup, int ts_index) +static void rtnl_get_ts_device_callback(void *ctx, int linkup, int ts_index) { int *dst = ctx; *dst = ts_index; } -int rtnl_get_ts_label(struct interface *iface) +int rtnl_get_ts_device(char *device, char *ts_device) { int err, fd; int ts_index = -1; @@ -58,13 +58,13 @@ int rtnl_get_ts_label(struct interface *iface) if (fd < 0) return fd; - err = rtnl_link_query(fd, iface->name); + err = rtnl_link_query(fd, device); if (err) { goto no_info; } - rtnl_link_status(fd, iface->name, rtnl_get_ts_label_callback, &ts_index); - if (ts_index > 0 && if_indextoname(ts_index, iface->ts_label)) + rtnl_link_status(fd, device, rtnl_get_ts_device_callback, &ts_index); + if (ts_index > 0 && if_indextoname(ts_index, ts_device)) err = 0; else err = -1; diff --git a/rtnl.h b/rtnl.h index 2906d74..f877cd2 100644 --- a/rtnl.h +++ b/rtnl.h @@ -20,8 +20,6 @@ #ifndef HAVE_RTNL_H #define HAVE_RTNL_H -#include "config.h" - typedef void (*rtnl_callback)(void *ctx, int linkup, int ts_index); /** @@ -32,11 +30,14 @@ typedef void (*rtnl_callback)(void *ctx, int linkup, int ts_index); int rtnl_close(int fd); /** - * Get interface ts_label information - * @param iface struct interface. - * @return Zero on success, or -1 on error. + * Get name of the slave interface which timestamps packets going through + * a master interface (e.g. bond0) + * @param device Name of the master interface. + * @param ts_device Buffer for the name of the slave interface, which must be + * at least IF_NAMESIZE bytes long. + * @return Zero on success, or -1 on error. */ -int rtnl_get_ts_label(struct interface *iface); +int rtnl_get_ts_device(char *device, char *ts_device); /** * Request the link status from the kernel.