Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working/chopps/ospf yang fixes #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/routing_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ const struct frr_yang_module_info frr_routing_info = {
.cbs = {
.create = routing_control_plane_protocols_control_plane_protocol_create,
.destroy = routing_control_plane_protocols_control_plane_protocol_destroy,
}
.get_next = routing_control_plane_protocols_control_plane_protocol_get_next,
.get_keys = routing_control_plane_protocols_control_plane_protocol_get_keys,
.lookup_entry = routing_control_plane_protocols_control_plane_protocol_lookup_entry,
},
},
{
.xpath = NULL,
Expand Down
6 changes: 6 additions & 0 deletions lib/routing_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ int routing_control_plane_protocols_control_plane_protocol_create(
struct nb_cb_create_args *args);
int routing_control_plane_protocols_control_plane_protocol_destroy(
struct nb_cb_destroy_args *args);
const void *routing_control_plane_protocols_control_plane_protocol_get_next(
struct nb_cb_get_next_args *args);
int routing_control_plane_protocols_control_plane_protocol_get_keys(
struct nb_cb_get_keys_args *args);
const void *routing_control_plane_protocols_control_plane_protocol_lookup_entry(
struct nb_cb_lookup_entry_args *args);

#define FRR_ROUTING_XPATH \
"/frr-routing:routing/control-plane-protocols/control-plane-protocol"
Expand Down
18 changes: 18 additions & 0 deletions lib/routing_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ int routing_control_plane_protocols_control_plane_protocol_destroy(
return NB_OK;
}

const void *routing_control_plane_protocols_control_plane_protocol_get_next(
struct nb_cb_get_next_args *args)
{
return NULL;
}

int routing_control_plane_protocols_control_plane_protocol_get_keys(
struct nb_cb_get_keys_args *args)
{
return NB_OK;
}

const void *routing_control_plane_protocols_control_plane_protocol_lookup_entry(
struct nb_cb_lookup_entry_args *args)
{
return NULL;
}

static void vrf_to_control_plane_protocol(const struct lyd_node *dnode,
char *xpath)
{
Expand Down
12 changes: 7 additions & 5 deletions ospfd/ospf_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1996,6 +1996,7 @@ const struct frr_yang_module_info frr_ospfd_info = {
.modify = routing_control_plane_protocols_control_plane_protocol_ospf_timers_lsa_min_interval_modify,
}
},
#if 0
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-ospfd:ospf/sr-mpls/srgb/lower-bound",
.cbs = {
Expand Down Expand Up @@ -2058,6 +2059,7 @@ const struct frr_yang_module_info frr_ospfd_info = {
.modify = routing_control_plane_protocols_control_plane_protocol_ospf_sr_mpls_bindings_connected_prefix_sid_map_connected_prefix_sid_last_hop_behavior_modify,
}
},
#endif
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-ospfd:ospf/nbma-neighbors/neighbor",
.cbs = {
Expand All @@ -2078,16 +2080,16 @@ const struct frr_yang_module_info frr_ospfd_info = {
}
},
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-ospfd:ospf/ip-networks/network",
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-ospfd:ospf/networks/network",
.cbs = {
.create = routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_network_create,
.destroy = routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_network_destroy,
.create = routing_control_plane_protocols_control_plane_protocol_ospf_networks_network_create,
.destroy = routing_control_plane_protocols_control_plane_protocol_ospf_networks_network_destroy,
}
},
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-ospfd:ospf/ip-networks/network/area",
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-ospfd:ospf/networks/network/area",
.cbs = {
.modify = routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_network_area_modify,
.modify = routing_control_plane_protocols_control_plane_protocol_ospf_networks_network_area_modify,
}
},
{
Expand Down
9 changes: 6 additions & 3 deletions ospfd/ospf_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,12 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_nbma_neighbors_n
int routing_control_plane_protocols_control_plane_protocol_ospf_nbma_neighbors_neighbor_destroy(struct nb_cb_destroy_args *args);
int routing_control_plane_protocols_control_plane_protocol_ospf_nbma_neighbors_neighbor_priority_modify(struct nb_cb_modify_args *args);
int routing_control_plane_protocols_control_plane_protocol_ospf_nbma_neighbors_neighbor_poll_interval_modify(struct nb_cb_modify_args *args);
int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_network_create(struct nb_cb_create_args *args);
int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_network_destroy(struct nb_cb_destroy_args *args);
int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_network_area_modify(struct nb_cb_modify_args *args);
int routing_control_plane_protocols_control_plane_protocol_ospf_networks_network_create(
struct nb_cb_create_args *args);
int routing_control_plane_protocols_control_plane_protocol_ospf_networks_network_destroy(
struct nb_cb_destroy_args *args);
int routing_control_plane_protocols_control_plane_protocol_ospf_networks_network_area_modify(
struct nb_cb_modify_args *args);
struct yang_data *routing_control_plane_protocols_control_plane_protocol_ospf_state_router_flags_router_flag_get_elem(struct nb_cb_get_elem_args *args);
const void *routing_control_plane_protocols_control_plane_protocol_ospf_state_router_flags_router_flag_get_next(struct nb_cb_get_next_args *args);
struct yang_data *routing_control_plane_protocols_control_plane_protocol_ospf_state_threads_abr_task_get_elem(struct nb_cb_get_elem_args *args);
Expand Down
74 changes: 50 additions & 24 deletions ospfd/ospf_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,24 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_create(struct nb
{
struct ospf *ospf;
unsigned short instance;
const char *vrf_name;
const char *istr, *vrf_name;
char *eistr;
bool created = false;

vrf_name = yang_dnode_get_string(args->dnode, "../vrf");
istr = yang_dnode_get_string(args->dnode, "../name");
instance = strtoul(istr, &eistr, 10);

if (args->event == NB_EV_VALIDATE) {
if (eistr == istr) {
return NB_ERR_VALIDATION;
}
}
assert(eistr != istr);

if (args->event != NB_EV_APPLY)
return NB_OK;

vrf_name = yang_dnode_get_string(args->dnode, "./../vrf");
instance = yang_dnode_get_uint8(args->dnode, "./../name");

ospf = ospf_get(instance, vrf_name, &created);

if (IS_DEBUG_OSPF_EVENT)
Expand Down Expand Up @@ -92,7 +101,8 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_explicit_router_

for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area))
if (area->full_nbrs) {
zlog_warn("For this router-id change to take effect, use \"clear ip ospf process\" command\n");
zlog_warn(
"For this router-id change to take effect, use \"clear ip ospf process\" command");
return NB_OK;
}

Expand All @@ -116,7 +126,8 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_explicit_router_

for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area))
if (area->full_nbrs) {
zlog_warn("For this router-id change to take effect, use \"clear ip ospf process\" command\n");
zlog_warn(
"For this router-id change to take effect, use \"clear ip ospf process\" command");
return NB_OK;
}

Expand Down Expand Up @@ -1931,9 +1942,11 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_nbma_neighbors_n
}

/*
* XPath: /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-ospfd:ospf/ip-networks/network
* XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-ospfd:ospf/networks/network
*/
int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_network_create(struct nb_cb_create_args *args)
int routing_control_plane_protocols_control_plane_protocol_ospf_networks_network_create(
struct nb_cb_create_args *args)
{
struct ospf *ospf;
struct prefix_ipv4 prefix;
Expand All @@ -1948,7 +1961,8 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_netw

/* XXX Doesn't check for automatically assigned router ID's */
if (ospf_id.s_addr) {
zlog_err("The network command is not supported in multi-instance ospf\n");
zlog_err(
"The network command is not supported in multi-instance ospf");
return NB_ERR_VALIDATION;
}

Expand All @@ -1958,7 +1972,8 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_netw
"/frr-interface:lib/interface/frr-ospfd:ospf/interface-address/area");

if (net_exists) {
zlog_warn("Please remove all ip ospf area x.x.x.x commands first.\n");
zlog_warn(
"Please remove all ip ospf area x.x.x.x commands first.");
return NB_ERR_VALIDATION;
}

Expand All @@ -1975,7 +1990,7 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_netw

ret = ospf_network_set(ospf, &prefix, area_id, format);
if (ret == 0) {
zlog_err("There is already same network statement.\n");
zlog_err("There is already same network statement.");
return NB_ERR;
}

Expand All @@ -1985,7 +2000,8 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_netw
return NB_OK;
}

int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_network_destroy(struct nb_cb_destroy_args *args)
int routing_control_plane_protocols_control_plane_protocol_ospf_networks_network_destroy(
struct nb_cb_destroy_args *args)
{
struct ospf *ospf;
struct prefix_ipv4 prefix;
Expand All @@ -2000,7 +2016,8 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_netw

/* XXX Doesn't check for automatically assigned router ID's */
if (ospf_id.s_addr) {
zlog_err("The network command is not supported in multi-instance ospf\n");
zlog_err(
"The network command is not supported in multi-instance ospf");
return NB_ERR_VALIDATION;
}

Expand All @@ -2017,7 +2034,8 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_netw

ret = ospf_network_unset(ospf, &prefix, area_id);
if (ret == 0) {
zlog_err("Can't find specific network area configuration to delete.\n");
zlog_err(
"Can't find specific network area configuration to delete.");
return NB_ERR;
}

Expand All @@ -2028,9 +2046,11 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_netw
}

/*
* XPath: /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-ospfd:ospf/ip-networks/network/area
* XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-ospfd:ospf/networks/network/area
*/
int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_network_area_modify(struct nb_cb_modify_args *args)
int routing_control_plane_protocols_control_plane_protocol_ospf_networks_network_area_modify(
struct nb_cb_modify_args *args)
{
struct ospf *ospf;
struct prefix_ipv4 prefix;
Expand Down Expand Up @@ -2061,7 +2081,8 @@ int routing_control_plane_protocols_control_plane_protocol_ospf_ip_networks_netw
yang_dnode_get_ipv4(&area, args->dnode, NULL);

if (!IPV4_ADDR_SAME(&network->area_id, &area)) {
zlog_err("Directly changing network area is not supported\n");
zlog_err(
"Directly changing network area is not supported");
return NB_ERR_VALIDATION;
}
}
Expand Down Expand Up @@ -2852,22 +2873,24 @@ int lib_interface_ospf_area_modify(struct nb_cb_modify_args *args)
params = IF_DEF_PARAMS(ifp);

if (memcmp(ifp->name, "VLINK", 5) == 0) {
zlog_err("Cannot enable OSPF on a virtual link.\n");
zlog_err("Cannot enable OSPF on a virtual link.");
return NB_ERR_VALIDATION;
}

if (ospf) {
for (rn = route_top(ospf->networks); rn; rn = route_next(rn)) {
if (rn->info != NULL) {
zlog_err("Please remove all network commands first.\n");
zlog_err(
"Please remove all network commands first.");
return NB_ERR_VALIDATION;
}
}
}

if (OSPF_IF_PARAM_CONFIGURED(params, if_area)
&& !IPV4_ADDR_SAME(&params->if_area, &area_id)) {
zlog_err("Must remove previous area config before changing ospf area \n");
zlog_err(
"Must remove previous area config before changing ospf area.");
return NB_ERR_VALIDATION;
}

Expand Down Expand Up @@ -3442,30 +3465,33 @@ int lib_interface_ospf_interface_address_area_modify(struct nb_cb_modify_args *a
params = IF_DEF_PARAMS(ifp);

if (memcmp(ifp->name, "VLINK", 5) == 0) {
zlog_err("Cannot enable OSPF on a virtual link.\n");
zlog_err("Cannot enable OSPF on a virtual link.");
return NB_ERR_VALIDATION;
}

if (ospf) {
for (rn = route_top(ospf->networks); rn; rn = route_next(rn)) {
if (rn->info != NULL) {
zlog_err("Please remove all network commands first.\n");
zlog_err(
"Please remove all network commands first.");
return NB_ERR_VALIDATION;
}
}
}

if (OSPF_IF_PARAM_CONFIGURED(params, if_area)
&& !IPV4_ADDR_SAME(&params->if_area, &area_id)) {
zlog_err("Must remove previous area config before changing ospf area \n");
zlog_err(
"Must remove previous area config before changing ospf area.");
return NB_ERR_VALIDATION;
}

// do not overwrite previously configured address-level params
params = ospf_get_if_params((ifp), (addr));
if (OSPF_IF_PARAM_CONFIGURED(params, if_area)
&& !IPV4_ADDR_SAME(&params->if_area, &area_id)) {
zlog_err("Must remove previous area/address config before changing ospf area\n");
zlog_err(
"Must remove previous area/address config before changing ospf area.");
return NB_ERR_VALIDATION;
}

Expand Down
Loading