src/confd: augment ietf-ip with an 'autoconf' setting also for IPv4

This patch adds a first Infix model to augment ietf-ip with a node,
similar to the IPv6 'autoconf' node, also for IPv4.  For IPv6 the
autoconf feature comes built-in, for IPv4 it is defined in RFC3927.

The setting behaves the same as for IPv6, but in the case of IPv4 we
enable avahi-autoipd per interface to acquire the 169.254/16 address.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2023-04-27 09:59:35 +02:00
committed by Tobias Waldekranz
parent ae62c20d40
commit 8b9504ffa5
2 changed files with 66 additions and 1 deletions
+19 -1
View File
@@ -35,6 +35,7 @@ static const struct srx_module_requirement ietf_if_reqs[] = {
{ .dir = YANG_PATH_, .name = "ietf-interfaces", .rev = "2018-02-20", .features = iffeat },
{ .dir = YANG_PATH_, .name = "iana-if-type", .rev = "2023-01-26" },
{ .dir = YANG_PATH_, .name = "ietf-ip", .rev = "2018-02-22", .features = ipfeat },
{ .dir = YANG_PATH_, .name = "infix-ip", .rev = "2023-04-24" },
{ NULL }
};
@@ -232,6 +233,16 @@ static int ifchange_cand(sr_session_ctx_t *session, uint32_t sub_id, const char
return SR_ERR_OK;
}
static void zeroconf_init(char *ifname)
{
systemf("initctl enable zeroconf@%s.conf", ifname);
}
static void zeroconf_exit(char *ifname)
{
systemf("initctl disable zeroconf@%s.conf", ifname);
}
static int ifchange(sr_session_ctx_t *session, uint32_t sub_id, const char *module,
const char *xpath, sr_event_t event, unsigned request_id, void *priv)
{
@@ -265,8 +276,15 @@ static int ifchange(sr_session_ctx_t *session, uint32_t sub_id, const char *modu
"/proc/sys/net/ipv4/conf/%s/forwarding", ifname);
systemf("ip addr flush dev %s", ifname);
if (!srx_enabled(session, "%s/ietf-ip:ipv4/enabled", xpath))
if (!srx_enabled(session, "%s/ietf-ip:ipv4/enabled", xpath)) {
zeroconf_exit(ifname);
goto ipv6;
}
if (!srx_enabled(session, "%s/ietf-ip:ipv4/autoconf/enabled", xpath))
zeroconf_exit(ifname);
else
zeroconf_init(ifname);
snprintf(path, sizeof(path), "%s/ietf-ip:ipv4/address", xpath);
rc = sr_get_items(session, path, 0, 0, &addr, &addrcnt);
+47
View File
@@ -0,0 +1,47 @@
module infix-ip {
yang-version 1.1;
namespace "urn:infix:params:xml:ns:yang:infix-ip";
prefix infix-ip;
import ietf-interfaces {
prefix if;
}
import ietf-ip {
prefix ip;
}
import ietf-inet-types {
prefix inet;
}
import ietf-yang-types {
prefix yang;
}
description
"This module augments ietf-ip with an IPv4 link-local autoconf";
revision 2023-04-24 {
description
"Initial revision.";
reference
"RFC 7277: A YANG Data Model for IP Management";
}
/*
* Data nodes
*/
augment "/if:interfaces/if:interface/ip:ipv4" {
container autoconf {
description
"Parameters to control the autoconfiguration of IPv4 address.";
leaf enabled {
type boolean;
default false;
description
"Use a ZeroConf/IPv4LL agent to retrieve an 169.254/16 address.";
reference
"RFC 3927: Dynamic Configuration of IPv4 Link-Local Addresses";
}
}
}
}