mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 07:33:01 +02:00
confd: Let products declare quirks of particular interfaces
Ideally, all drivers should behave the same. Alas, that is not the world we live in. For quirks that we can not reliably probe for in any other way, let products supply a JSON file that declares them.
This commit is contained in:
@@ -126,6 +126,12 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **priv)
|
||||
confd.root = json_load_file("/run/system.json", 0, NULL);
|
||||
if (!confd.root)
|
||||
goto err;
|
||||
|
||||
/* An optional file that contains hardware specific quirks for
|
||||
* the network interfaces on running board.
|
||||
*/
|
||||
confd.ifquirks = json_load_file("/etc/product/interface-quirks.json", 0, NULL);
|
||||
|
||||
rc = ietf_interfaces_init(&confd);
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
@@ -124,6 +124,7 @@ struct confd {
|
||||
sr_subscription_ctx_t *sub;
|
||||
sr_subscription_ctx_t *fsub; /* factory-default sub */
|
||||
json_t *root;
|
||||
json_t *ifquirks;
|
||||
struct dagger netdag;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,21 @@
|
||||
|
||||
#include "ietf-interfaces.h"
|
||||
|
||||
bool iface_has_quirk(const char *ifname, const char *quirkname)
|
||||
{
|
||||
struct json_t *iface, *quirk;
|
||||
|
||||
if (!confd.ifquirks)
|
||||
return false;
|
||||
|
||||
iface = json_object_get(confd.ifquirks, ifname);
|
||||
if (!iface)
|
||||
return false;
|
||||
|
||||
quirk = json_object_get(iface, quirkname);
|
||||
|
||||
return quirk ? json_is_true(quirk) : false;
|
||||
}
|
||||
static bool iface_is_phys(const char *ifname)
|
||||
{
|
||||
bool is_phys = false;
|
||||
|
||||
@@ -92,6 +92,8 @@ static inline bool is_member_port(struct lyd_node *cif)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool iface_has_quirk(const char *ifname, const char *quirkname);
|
||||
|
||||
|
||||
/* ieee802-ethernet-interface.c */
|
||||
int netdag_gen_ethtool(struct dagger *net, struct lyd_node *cif, struct lyd_node *dif);
|
||||
|
||||
Reference in New Issue
Block a user