mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-29 20:23:01 +02:00
confd: add support for dummy interfaces
Dummy interfaces are useful for configuring routes and testing network services without having to allocate physical or virtual interfaces. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -227,6 +227,8 @@ static int ifchange_cand_infer_type(sr_session_ctx_t *session, const char *path)
|
||||
inferred.data.string_val = "infix-if-type:bridge";
|
||||
else if (!fnmatch("docker+([0-9])", ifname, FNM_EXTMATCH))
|
||||
inferred.data.string_val = "infix-if-type:bridge";
|
||||
else if (!fnmatch("dummy+([0-9])", ifname, FNM_EXTMATCH))
|
||||
inferred.data.string_val = "infix-if-type:dummy";
|
||||
else if (!fnmatch("podman+([0-9])", ifname, FNM_EXTMATCH))
|
||||
inferred.data.string_val = "infix-if-type:bridge";
|
||||
else if (!fnmatch("lag+([0-9])", ifname, FNM_EXTMATCH))
|
||||
@@ -1522,6 +1524,16 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int netdag_gen_dummy(struct dagger *net, struct lyd_node *dif,
|
||||
struct lyd_node *cif, FILE *ip)
|
||||
{
|
||||
const char *ifname = lydx_get_cattr(cif, "name");
|
||||
|
||||
fprintf(ip, "link add dev %s type dummy\n", ifname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int netdag_gen_veth(struct dagger *net, struct lyd_node *dif,
|
||||
struct lyd_node *cif, FILE *ip)
|
||||
{
|
||||
@@ -1665,6 +1677,8 @@ static int netdag_gen_afspec_add(sr_session_ctx_t *session, struct dagger *net,
|
||||
|
||||
if (!strcmp(iftype, "infix-if-type:bridge")) {
|
||||
err = netdag_gen_bridge(session, net, dif, cif, ip, 1);
|
||||
} else if (!strcmp(iftype, "infix-if-type:dummy")) {
|
||||
err = netdag_gen_dummy(net, NULL, cif, ip);
|
||||
} else if (!strcmp(iftype, "infix-if-type:veth")) {
|
||||
err = netdag_gen_veth(net, NULL, cif, ip);
|
||||
} else if (!strcmp(iftype, "infix-if-type:vlan")) {
|
||||
|
||||
@@ -26,7 +26,7 @@ MODULES=(
|
||||
"infix-hardware@2024-04-25.yang"
|
||||
"ieee802-dot1q-types@2022-10-29.yang"
|
||||
"infix-ip@2024-09-16.yang"
|
||||
"infix-if-type@2024-01-29.yang"
|
||||
"infix-if-type@2024-10-13.yang"
|
||||
"infix-routing@2024-10-01.yang"
|
||||
"ieee802-dot1ab-lldp@2022-03-15.yang"
|
||||
"infix-lldp@2023-08-23.yang"
|
||||
|
||||
@@ -11,15 +11,20 @@ module infix-if-type {
|
||||
contact "kernelkit@googlegroups.com";
|
||||
description "Infix extensions to IANA interfaces types";
|
||||
|
||||
revision 2023-08-21 {
|
||||
description "Add infix-inteface-type to reduce number of supported
|
||||
interfaces. The derived identities are based on both
|
||||
this new identity and their parent iana-if-type.";
|
||||
revision 2024-10-13 {
|
||||
description "Add new interface type dummy.";
|
||||
reference "internal";
|
||||
}
|
||||
|
||||
revision 2024-01-29 {
|
||||
description "Add new interface type etherlike";
|
||||
description "Add new interface type etherlike.";
|
||||
reference "internal";
|
||||
}
|
||||
|
||||
revision 2023-08-21 {
|
||||
description "Add infix-inteface-type to reduce number of supported
|
||||
interfaces. The derived identities are based on both
|
||||
this new identity and their parent iana-if-type.";
|
||||
reference "internal";
|
||||
}
|
||||
|
||||
@@ -42,6 +47,11 @@ module infix-if-type {
|
||||
base ianaift:bridge;
|
||||
description "IEEE bridge interface.";
|
||||
}
|
||||
identity dummy {
|
||||
base infix-interface-type;
|
||||
base ianaift:other;
|
||||
description "Linux dummy interface. Useful mostly for testing.";
|
||||
}
|
||||
identity ethernet {
|
||||
base infix-interface-type;
|
||||
base ianaift:ethernetCsmacd;
|
||||
|
||||
@@ -45,6 +45,9 @@ def json_get_yang_type(iface_in):
|
||||
if iface_in['linkinfo']['info_kind'] == "dsa":
|
||||
return "infix-if-type:ethernet"
|
||||
|
||||
if iface_in['linkinfo']['info_kind'] == "dummy":
|
||||
return "infix-if-type:dummy"
|
||||
|
||||
# Fallback
|
||||
return "infix-if-type:ethernet"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user