mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 23:43:20 +02:00
ospf: add point-to-multipoint and hybrid interface type support
This commit is contained in:
+35
-1
@@ -154,6 +154,17 @@ int parse_rip(sr_session_ctx_t *session, struct lyd_node *rip, FILE *fp)
|
||||
return num_interfaces;
|
||||
}
|
||||
|
||||
static const char *ospf_network_type(const char *yang_type)
|
||||
{
|
||||
if (!strcmp(yang_type, "hybrid"))
|
||||
return "point-to-multipoint";
|
||||
if (!strcmp(yang_type, "point-to-multipoint"))
|
||||
return "point-to-multipoint non-broadcast";
|
||||
|
||||
/* broadcast, non-broadcast, point-to-point pass through unchanged */
|
||||
return yang_type;
|
||||
}
|
||||
|
||||
int parse_ospf_interfaces(sr_session_ctx_t *session, struct lyd_node *areas, FILE *fp)
|
||||
{
|
||||
struct lyd_node *interface, *interfaces, *area;
|
||||
@@ -203,7 +214,7 @@ int parse_ospf_interfaces(sr_session_ctx_t *session, struct lyd_node *areas, FIL
|
||||
if (passive)
|
||||
fputs(" ip ospf passive\n", fp);
|
||||
if (interface_type)
|
||||
fprintf(fp, " ip ospf network %s\n", interface_type);
|
||||
fprintf(fp, " ip ospf network %s\n", ospf_network_type(interface_type));
|
||||
if (cost)
|
||||
fprintf(fp, " ip ospf cost %s\n", cost);
|
||||
}
|
||||
@@ -226,6 +237,28 @@ int parse_ospf_redistribute(sr_session_ctx_t *session, struct lyd_node *redistri
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void parse_ospf_static_neighbors(struct lyd_node *areas, FILE *fp)
|
||||
{
|
||||
struct lyd_node *area, *interface, *interfaces, *neighbors, *neighbor;
|
||||
|
||||
LY_LIST_FOR(lyd_child(areas), area) {
|
||||
interfaces = lydx_get_child(area, "interfaces");
|
||||
|
||||
LY_LIST_FOR(lyd_child(interfaces), interface) {
|
||||
neighbors = lydx_get_child(interface, "static-neighbors");
|
||||
if (!neighbors)
|
||||
continue;
|
||||
|
||||
LY_LIST_FOR(lyd_child(neighbors), neighbor) {
|
||||
const char *id = lydx_get_cattr(neighbor, "identifier");
|
||||
|
||||
if (id)
|
||||
fprintf(fp, " neighbor %s\n", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int parse_ospf_areas(sr_session_ctx_t *session, struct lyd_node *areas, FILE *fp)
|
||||
{
|
||||
int areas_configured = 0;
|
||||
@@ -315,6 +348,7 @@ int parse_ospf(sr_session_ctx_t *session, struct lyd_node *ospf)
|
||||
fputs("router ospf\n", fp);
|
||||
num_areas = parse_ospf_areas(session, areas, fp);
|
||||
parse_ospf_redistribute(session, lydx_get_child(ospf, "redistribute"), fp);
|
||||
parse_ospf_static_neighbors(areas, fp);
|
||||
default_route = lydx_get_child(ospf, "default-route-advertise");
|
||||
if (default_route) {
|
||||
/* enable is obsolete in favor for enabled. */
|
||||
|
||||
@@ -14,7 +14,7 @@ MODULES=(
|
||||
"ietf-routing@2018-03-13.yang"
|
||||
"ietf-ipv6-unicast-routing@2018-03-13.yang"
|
||||
"ietf-ipv4-unicast-routing@2018-03-13.yang"
|
||||
"ietf-ospf@2022-10-19.yang -e bfd -e explicit-router-id"
|
||||
"ietf-ospf@2022-10-19.yang -e bfd -e explicit-router-id -e hybrid-interface"
|
||||
"ietf-rip@2020-02-20.yang"
|
||||
"iana-bfd-types@2021-10-21.yang"
|
||||
"ietf-bfd-types@2022-09-22.yang"
|
||||
@@ -31,7 +31,7 @@ MODULES=(
|
||||
"ieee802-dot1q-types@2022-10-29.yang"
|
||||
"infix-ip@2025-11-02.yang"
|
||||
"infix-if-type@2026-01-07.yang"
|
||||
"infix-routing@2025-12-02.yang"
|
||||
"infix-routing@2026-03-04.yang "
|
||||
"ieee802-dot1ab-lldp@2022-03-15.yang"
|
||||
"infix-lldp@2025-05-05.yang"
|
||||
"infix-dhcp-common@2025-12-21.yang"
|
||||
|
||||
@@ -26,6 +26,12 @@ module infix-routing {
|
||||
contact "kernelkit@googlegroups.com";
|
||||
description "Deviations and augments for ietf-routing, ietf-ospf, and ietf-rip.";
|
||||
|
||||
revision 2026-03-04 {
|
||||
description "Remove interface-type deviation to expose standard ietf-ospf
|
||||
interface types including point-to-multipoint and hybrid.
|
||||
Un-deviate static-neighbors for non-broadcast P2MP support.";
|
||||
}
|
||||
|
||||
revision 2025-12-02 {
|
||||
description "Add configurable OSPF debug logging container.
|
||||
Add RIP (Routing Information Protocol) support.";
|
||||
@@ -247,18 +253,6 @@ module infix-routing {
|
||||
}
|
||||
|
||||
/* OSPF */
|
||||
typedef infix-ospf-interface-type {
|
||||
type enumeration {
|
||||
enum broadcast {
|
||||
description
|
||||
"Specifies an OSPF broadcast multi-access network.";
|
||||
}
|
||||
enum point-to-point {
|
||||
description
|
||||
"Specifies an OSPF point-to-point network.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol" {
|
||||
@@ -367,11 +361,6 @@ module infix-routing {
|
||||
}
|
||||
}
|
||||
|
||||
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:interfaces/ospf:interface/ospf:interface-type" {
|
||||
deviate replace {
|
||||
type infix-ospf-interface-type;
|
||||
}
|
||||
}
|
||||
|
||||
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:auto-cost" {
|
||||
deviate not-supported;
|
||||
@@ -463,10 +452,6 @@ module infix-routing {
|
||||
}
|
||||
|
||||
/* OSPF Area Interface */
|
||||
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:interfaces/ospf:interface/ospf:static-neighbors"
|
||||
{
|
||||
deviate not-supported;
|
||||
}
|
||||
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:interfaces/ospf:interface/ospf:multi-areas" {
|
||||
deviate not-supported;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user