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 <mlichvar@redhat.com>master
parent
29cd088347
commit
742f878821
2
clock.c
2
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 &&
|
||||
|
|
2
nsm.c
2
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);
|
||||
}
|
||||
|
|
10
rtnl.c
10
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;
|
||||
|
|
13
rtnl.h
13
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.
|
||||
|
|
Loading…
Reference in New Issue