mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 21:57:36 +00:00
commit
650f3a558b
@ -42,6 +42,7 @@
|
|||||||
#include "distribute.h"
|
#include "distribute.h"
|
||||||
#include "libfrr.h"
|
#include "libfrr.h"
|
||||||
#include "routemap.h"
|
#include "routemap.h"
|
||||||
|
#include "nexthop_group.h"
|
||||||
|
|
||||||
#include "sharp_zebra.h"
|
#include "sharp_zebra.h"
|
||||||
#include "sharp_vty.h"
|
#include "sharp_vty.h"
|
||||||
@ -150,6 +151,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
|
|
||||||
master = frr_init();
|
master = frr_init();
|
||||||
|
|
||||||
|
nexthop_group_init(NULL, NULL, NULL, NULL);
|
||||||
vrf_init(NULL, NULL, NULL, NULL, NULL);
|
vrf_init(NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
access_list_init();
|
access_list_init();
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "vrf.h"
|
#include "vrf.h"
|
||||||
#include "zclient.h"
|
#include "zclient.h"
|
||||||
|
#include "nexthop_group.h"
|
||||||
|
|
||||||
#include "sharpd/sharp_zebra.h"
|
#include "sharpd/sharp_zebra.h"
|
||||||
#include "sharpd/sharp_vty.h"
|
#include "sharpd/sharp_vty.h"
|
||||||
@ -81,7 +82,7 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
|
|||||||
|
|
||||||
DEFPY (install_routes,
|
DEFPY (install_routes,
|
||||||
install_routes_cmd,
|
install_routes_cmd,
|
||||||
"sharp install routes A.B.C.D$start nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6> (1-1000000)$routes [instance (0-255)$instance]",
|
"sharp install routes A.B.C.D$start <nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|nexthop-group NAME$nexthop_group> (1-1000000)$routes [instance (0-255)$instance]",
|
||||||
"Sharp routing Protocol\n"
|
"Sharp routing Protocol\n"
|
||||||
"install some routes\n"
|
"install some routes\n"
|
||||||
"Routes to install\n"
|
"Routes to install\n"
|
||||||
@ -89,6 +90,8 @@ DEFPY (install_routes,
|
|||||||
"Nexthop to use(Can be an IPv4 or IPv6 address)\n"
|
"Nexthop to use(Can be an IPv4 or IPv6 address)\n"
|
||||||
"V4 Nexthop address to use\n"
|
"V4 Nexthop address to use\n"
|
||||||
"V6 Nexthop address to use\n"
|
"V6 Nexthop address to use\n"
|
||||||
|
"Nexthop-Group to use\n"
|
||||||
|
"The Name of the nexthop-group\n"
|
||||||
"How many to create\n"
|
"How many to create\n"
|
||||||
"Instance to use\n"
|
"Instance to use\n"
|
||||||
"Instance\n")
|
"Instance\n")
|
||||||
@ -96,6 +99,7 @@ DEFPY (install_routes,
|
|||||||
int i;
|
int i;
|
||||||
struct prefix p;
|
struct prefix p;
|
||||||
struct nexthop nhop;
|
struct nexthop nhop;
|
||||||
|
struct nexthop_group nhg;
|
||||||
uint32_t temp;
|
uint32_t temp;
|
||||||
|
|
||||||
total_routes = routes;
|
total_routes = routes;
|
||||||
@ -103,24 +107,38 @@ DEFPY (install_routes,
|
|||||||
|
|
||||||
memset(&p, 0, sizeof(p));
|
memset(&p, 0, sizeof(p));
|
||||||
memset(&nhop, 0, sizeof(nhop));
|
memset(&nhop, 0, sizeof(nhop));
|
||||||
|
memset(&nhg, 0, sizeof(nhg));
|
||||||
|
|
||||||
p.family = AF_INET;
|
p.family = AF_INET;
|
||||||
p.prefixlen = 32;
|
p.prefixlen = 32;
|
||||||
p.u.prefix4 = start;
|
p.u.prefix4 = start;
|
||||||
|
|
||||||
if (nexthop4.s_addr != INADDR_ANY) {
|
if (nexthop_group) {
|
||||||
nhop.gate.ipv4 = nexthop4;
|
struct nexthop_group_cmd *nhgc = nhgc_find(nexthop_group);
|
||||||
nhop.type = NEXTHOP_TYPE_IPV4;
|
if (!nhgc) {
|
||||||
} else {
|
vty_out(vty,
|
||||||
memcpy(&nhop.gate.ipv6, &nexthop6, IPV6_MAX_BYTELEN);
|
"Specified Nexthop Group: %s does not exist\n",
|
||||||
nhop.type = NEXTHOP_TYPE_IPV6;
|
nexthop_group);
|
||||||
}
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
nhg.nexthop = nhgc->nhg.nexthop;
|
||||||
|
} else {
|
||||||
|
if (nexthop4.s_addr != INADDR_ANY) {
|
||||||
|
nhop.gate.ipv4 = nexthop4;
|
||||||
|
nhop.type = NEXTHOP_TYPE_IPV4;
|
||||||
|
} else {
|
||||||
|
nhop.gate.ipv6 = nexthop6;
|
||||||
|
nhop.type = NEXTHOP_TYPE_IPV6;
|
||||||
|
}
|
||||||
|
|
||||||
|
nhg.nexthop = &nhop;
|
||||||
|
}
|
||||||
zlog_debug("Inserting %ld routes", routes);
|
zlog_debug("Inserting %ld routes", routes);
|
||||||
|
|
||||||
temp = ntohl(p.u.prefix4.s_addr);
|
temp = ntohl(p.u.prefix4.s_addr);
|
||||||
for (i = 0; i < routes; i++) {
|
for (i = 0; i < routes; i++) {
|
||||||
route_add(&p, (uint8_t)instance, &nhop);
|
route_add(&p, (uint8_t)instance, &nhg);
|
||||||
p.u.prefix4.s_addr = htonl(++temp);
|
p.u.prefix4.s_addr = htonl(++temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "plist.h"
|
#include "plist.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "nexthop.h"
|
#include "nexthop.h"
|
||||||
|
#include "nexthop_group.h"
|
||||||
|
|
||||||
#include "sharp_zebra.h"
|
#include "sharp_zebra.h"
|
||||||
|
|
||||||
@ -176,10 +177,12 @@ void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label)
|
|||||||
zclient_send_vrf_label(zclient, vrf_id, afi, label, ZEBRA_LSP_SHARP);
|
zclient_send_vrf_label(zclient, vrf_id, afi, label, ZEBRA_LSP_SHARP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void route_add(struct prefix *p, uint8_t instance, struct nexthop *nh)
|
void route_add(struct prefix *p, uint8_t instance, struct nexthop_group *nhg)
|
||||||
{
|
{
|
||||||
struct zapi_route api;
|
struct zapi_route api;
|
||||||
struct zapi_nexthop *api_nh;
|
struct zapi_nexthop *api_nh;
|
||||||
|
struct nexthop *nh;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
memset(&api, 0, sizeof(api));
|
memset(&api, 0, sizeof(api));
|
||||||
api.vrf_id = VRF_DEFAULT;
|
api.vrf_id = VRF_DEFAULT;
|
||||||
@ -191,12 +194,35 @@ void route_add(struct prefix *p, uint8_t instance, struct nexthop *nh)
|
|||||||
SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION);
|
SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION);
|
||||||
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
|
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
|
||||||
|
|
||||||
api_nh = &api.nexthops[0];
|
for (ALL_NEXTHOPS_PTR(nhg, nh)) {
|
||||||
api_nh->vrf_id = VRF_DEFAULT;
|
api_nh = &api.nexthops[i];
|
||||||
api_nh->gate = nh->gate;
|
api_nh->vrf_id = VRF_DEFAULT;
|
||||||
api_nh->type = nh->type;
|
api_nh->type = nh->type;
|
||||||
api_nh->ifindex = nh->ifindex;
|
switch (nh->type) {
|
||||||
api.nexthop_num = 1;
|
case NEXTHOP_TYPE_IPV4:
|
||||||
|
api_nh->gate = nh->gate;
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||||
|
api_nh->gate = nh->gate;
|
||||||
|
api_nh->ifindex = nh->ifindex;
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
|
api_nh->ifindex = nh->ifindex;
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_IPV6:
|
||||||
|
memcpy(&api_nh->gate.ipv6, &nh->gate.ipv6, 16);
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
|
api_nh->ifindex = nh->ifindex;
|
||||||
|
memcpy(&api_nh->gate.ipv6, &nh->gate.ipv6, 16);
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_BLACKHOLE:
|
||||||
|
api_nh->bh_type = nh->bh_type;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
api.nexthop_num = i;
|
||||||
|
|
||||||
zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
|
zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
extern void sharp_zebra_init(void);
|
extern void sharp_zebra_init(void);
|
||||||
|
|
||||||
extern void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label);
|
extern void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label);
|
||||||
extern void route_add(struct prefix *p, uint8_t instance, struct nexthop *nh);
|
extern void route_add(struct prefix *p, uint8_t instance,
|
||||||
|
struct nexthop_group *nhg);
|
||||||
extern void route_delete(struct prefix *p, uint8_t instance);
|
extern void route_delete(struct prefix *p, uint8_t instance);
|
||||||
extern void sharp_zebra_nexthop_watch(struct prefix *p, bool watch);
|
extern void sharp_zebra_nexthop_watch(struct prefix *p, bool watch);
|
||||||
#endif
|
#endif
|
||||||
|
@ -109,7 +109,7 @@ sub scan_file {
|
|||||||
$protocol = "VTYSH_ZEBRA";
|
$protocol = "VTYSH_ZEBRA";
|
||||||
}
|
}
|
||||||
elsif ($file =~ /lib\/nexthop_group\.c$/) {
|
elsif ($file =~ /lib\/nexthop_group\.c$/) {
|
||||||
$protocol = "VTYSH_PBRD";
|
$protocol = "VTYSH_PBRD | VTYSH_SHARPD";
|
||||||
}
|
}
|
||||||
elsif ($file =~ /lib\/plist\.c$/) {
|
elsif ($file =~ /lib\/plist\.c$/) {
|
||||||
if ($defun_array[1] =~ m/ipv6/) {
|
if ($defun_array[1] =~ m/ipv6/) {
|
||||||
|
@ -2110,7 +2110,7 @@ DEFSH(VTYSH_ZEBRA, vtysh_no_logicalrouter_cmd,
|
|||||||
"The Name Space\n"
|
"The Name Space\n"
|
||||||
"The file name in " NS_RUN_DIR ", or a full pathname\n")
|
"The file name in " NS_RUN_DIR ", or a full pathname\n")
|
||||||
|
|
||||||
DEFUNSH(VTYSH_PBRD, vtysh_nexthop_group, vtysh_nexthop_group_cmd,
|
DEFUNSH(VTYSH_PBRD | VTYSH_SHARPD, vtysh_nexthop_group, vtysh_nexthop_group_cmd,
|
||||||
"nexthop-group NAME",
|
"nexthop-group NAME",
|
||||||
"Nexthop Group configuration\n"
|
"Nexthop Group configuration\n"
|
||||||
"Name of the Nexthop Group\n")
|
"Name of the Nexthop Group\n")
|
||||||
@ -2119,7 +2119,8 @@ DEFUNSH(VTYSH_PBRD, vtysh_nexthop_group, vtysh_nexthop_group_cmd,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFSH(VTYSH_PBRD, vtysh_no_nexthop_group_cmd, "no nexthop-group NAME",
|
DEFSH(VTYSH_PBRD | VTYSH_SHARPD, vtysh_no_nexthop_group_cmd,
|
||||||
|
"no nexthop-group NAME",
|
||||||
NO_STR
|
NO_STR
|
||||||
"Nexthop Group Configuration\n"
|
"Nexthop Group Configuration\n"
|
||||||
"Name of the Nexthop Group\n")
|
"Name of the Nexthop Group\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user