interface: Introduce a method to initialize the time stamping label.

In many cases, the time stamping label will be the same as the name of
the interface.  In order to prevent users from open coding the logic that
initializes the label from the interface name, this patch add an
appropriate method.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
master
Richard Cochran 2020-02-09 11:40:24 -08:00
parent 6d73e755c3
commit b802e3b784
2 changed files with 13 additions and 0 deletions

View File

@ -6,6 +6,13 @@
*/ */
#include "interface.h" #include "interface.h"
void interface_ensure_tslabel(struct interface *iface)
{
if (!iface->ts_label[0]) {
strncpy(iface->ts_label, iface->name, MAX_IFNAME_SIZE);
}
}
int interface_get_tsinfo(struct interface *iface) int interface_get_tsinfo(struct interface *iface)
{ {
return sk_get_ts_info(iface->ts_label, &iface->ts_info); return sk_get_ts_info(iface->ts_label, &iface->ts_info);

View File

@ -24,6 +24,12 @@ struct interface {
struct sk_ts_info ts_info; struct sk_ts_info ts_info;
}; };
/**
* Ensures that an interface has a proper time stamping label.
* @param iface The interface of interest.
*/
void interface_ensure_tslabel(struct interface *iface);
/** /**
* Populate the time stamping information of a given interface. * Populate the time stamping information of a given interface.
* @param iface The interface of interest. * @param iface The interface of interest.