diff --git a/src/confd/src/core.c b/src/confd/src/core.c index c2c98865..d3168c12 100644 --- a/src/confd/src/core.c +++ b/src/confd/src/core.c @@ -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; diff --git a/src/confd/src/core.h b/src/confd/src/core.h index 0d6d1758..e2a8b0a8 100644 --- a/src/confd/src/core.h +++ b/src/confd/src/core.h @@ -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; }; diff --git a/src/confd/src/ietf-interfaces.c b/src/confd/src/ietf-interfaces.c index e874f5ec..e0cfe77a 100644 --- a/src/confd/src/ietf-interfaces.c +++ b/src/confd/src/ietf-interfaces.c @@ -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; diff --git a/src/confd/src/ietf-interfaces.h b/src/confd/src/ietf-interfaces.h index b6a900f3..25287df3 100644 --- a/src/confd/src/ietf-interfaces.h +++ b/src/confd/src/ietf-interfaces.h @@ -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);