mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-06 11:04:41 +00:00
Merge pull request #3390 from pguibert6WIND/bgp_flowspec_new_redirect_ip_draft
bgpd: add new draft for redirect ip for flowspec
This commit is contained in:
commit
ad395eb3d1
@ -688,9 +688,23 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
|
|||||||
/* Low-order octet of type. */
|
/* Low-order octet of type. */
|
||||||
sub_type = *pnt++;
|
sub_type = *pnt++;
|
||||||
if (sub_type != ECOMMUNITY_ROUTE_TARGET
|
if (sub_type != ECOMMUNITY_ROUTE_TARGET
|
||||||
&& sub_type != ECOMMUNITY_SITE_ORIGIN)
|
&& sub_type != ECOMMUNITY_SITE_ORIGIN) {
|
||||||
|
if (sub_type ==
|
||||||
|
ECOMMUNITY_FLOWSPEC_REDIRECT_IPV4 &&
|
||||||
|
type == ECOMMUNITY_ENCODE_IP) {
|
||||||
|
struct in_addr *ipv4 =
|
||||||
|
(struct in_addr *)pnt;
|
||||||
|
char ipv4str[INET_ADDRSTRLEN];
|
||||||
|
|
||||||
|
inet_ntop(AF_INET, ipv4,
|
||||||
|
ipv4str,
|
||||||
|
INET_ADDRSTRLEN);
|
||||||
|
len = sprintf(str_buf + str_pnt,
|
||||||
|
"NH:%s:%d",
|
||||||
|
ipv4str, pnt[5]);
|
||||||
|
} else
|
||||||
unk_ecom = 1;
|
unk_ecom = 1;
|
||||||
else
|
} else
|
||||||
len = ecommunity_rt_soo_str(str_buf + str_pnt,
|
len = ecommunity_rt_soo_str(str_buf + str_pnt,
|
||||||
pnt, type, sub_type,
|
pnt, type, sub_type,
|
||||||
format);
|
format);
|
||||||
|
@ -41,6 +41,10 @@
|
|||||||
#define ECOMMUNITY_REDIRECT_VRF 0x08
|
#define ECOMMUNITY_REDIRECT_VRF 0x08
|
||||||
#define ECOMMUNITY_TRAFFIC_MARKING 0x09
|
#define ECOMMUNITY_TRAFFIC_MARKING 0x09
|
||||||
#define ECOMMUNITY_REDIRECT_IP_NH 0x00
|
#define ECOMMUNITY_REDIRECT_IP_NH 0x00
|
||||||
|
/* from IANA: bgp-extended-communities/bgp-extended-communities.xhtml
|
||||||
|
* 0x0c Flow-spec Redirect to IPv4 - draft-ietf-idr-flowspec-redirect
|
||||||
|
*/
|
||||||
|
#define ECOMMUNITY_FLOWSPEC_REDIRECT_IPV4 0x0c
|
||||||
|
|
||||||
/* Low-order octet of the Extended Communities type field for EVPN types */
|
/* Low-order octet of the Extended Communities type field for EVPN types */
|
||||||
#define ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY 0x00
|
#define ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY 0x00
|
||||||
|
@ -315,7 +315,8 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
|
|||||||
}
|
}
|
||||||
if (attr->nexthop.s_addr != 0 &&
|
if (attr->nexthop.s_addr != 0 &&
|
||||||
display == NLRI_STRING_FORMAT_LARGE)
|
display == NLRI_STRING_FORMAT_LARGE)
|
||||||
vty_out(vty, "\tNH %-16s\n", inet_ntoa(attr->nexthop));
|
vty_out(vty, "\tNLRI NH %-16s\n",
|
||||||
|
inet_ntoa(attr->nexthop));
|
||||||
XFREE(MTYPE_ECOMMUNITY_STR, s);
|
XFREE(MTYPE_ECOMMUNITY_STR, s);
|
||||||
}
|
}
|
||||||
peer_uptime(path->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL);
|
peer_uptime(path->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL);
|
||||||
|
@ -638,6 +638,7 @@ static int bgp_pbr_build_and_validate_entry(struct prefix *p,
|
|||||||
struct prefix *src = NULL, *dst = NULL;
|
struct prefix *src = NULL, *dst = NULL;
|
||||||
int valid_prefix = 0;
|
int valid_prefix = 0;
|
||||||
afi_t afi = AFI_IP;
|
afi_t afi = AFI_IP;
|
||||||
|
struct bgp_pbr_entry_action *api_action_redirect_ip = NULL;
|
||||||
|
|
||||||
/* extract match from flowspec entries */
|
/* extract match from flowspec entries */
|
||||||
ret = bgp_flowspec_match_rules_fill((uint8_t *)p->u.prefix_flowspec.ptr,
|
ret = bgp_flowspec_match_rules_fill((uint8_t *)p->u.prefix_flowspec.ptr,
|
||||||
@ -688,10 +689,55 @@ static int bgp_pbr_build_and_validate_entry(struct prefix *p,
|
|||||||
(char)ECOMMUNITY_ENCODE_REDIRECT_IP_NH) &&
|
(char)ECOMMUNITY_ENCODE_REDIRECT_IP_NH) &&
|
||||||
(ecom_eval->val[1] ==
|
(ecom_eval->val[1] ==
|
||||||
(char)ECOMMUNITY_REDIRECT_IP_NH)) {
|
(char)ECOMMUNITY_REDIRECT_IP_NH)) {
|
||||||
|
/* in case the 2 ecom present,
|
||||||
|
* do not overwrite
|
||||||
|
* draft-ietf-idr-flowspec-redirect
|
||||||
|
*/
|
||||||
|
if (api_action_redirect_ip) {
|
||||||
|
if (api_action_redirect_ip->u
|
||||||
|
.zr.redirect_ip_v4.s_addr)
|
||||||
|
continue;
|
||||||
|
if (!path->attr->nexthop.s_addr)
|
||||||
|
continue;
|
||||||
|
api_action_redirect_ip->u
|
||||||
|
.zr.redirect_ip_v4.s_addr =
|
||||||
|
path->attr->nexthop.s_addr;
|
||||||
|
api_action_redirect_ip->u.zr.duplicate
|
||||||
|
= ecom_eval->val[7];
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
api_action->action = ACTION_REDIRECT_IP;
|
api_action->action = ACTION_REDIRECT_IP;
|
||||||
api_action->u.zr.redirect_ip_v4.s_addr =
|
api_action->u.zr.redirect_ip_v4.s_addr =
|
||||||
path->attr->nexthop.s_addr;
|
path->attr->nexthop.s_addr;
|
||||||
api_action->u.zr.duplicate = ecom_eval->val[7];
|
api_action->u.zr.duplicate =
|
||||||
|
ecom_eval->val[7];
|
||||||
|
api_action_redirect_ip = api_action;
|
||||||
|
}
|
||||||
|
} else if ((ecom_eval->val[0] ==
|
||||||
|
(char)ECOMMUNITY_ENCODE_IP) &&
|
||||||
|
(ecom_eval->val[1] ==
|
||||||
|
(char)ECOMMUNITY_FLOWSPEC_REDIRECT_IPV4)) {
|
||||||
|
/* in case the 2 ecom present,
|
||||||
|
* overwrite simpson draft
|
||||||
|
* update redirect ip fields
|
||||||
|
*/
|
||||||
|
if (api_action_redirect_ip) {
|
||||||
|
memcpy(&(api_action_redirect_ip->u
|
||||||
|
.zr.redirect_ip_v4.s_addr),
|
||||||
|
(ecom_eval->val+2), 4);
|
||||||
|
api_action_redirect_ip->u
|
||||||
|
.zr.duplicate =
|
||||||
|
ecom_eval->val[7];
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
api_action->action = ACTION_REDIRECT_IP;
|
||||||
|
memcpy(&(api_action->u
|
||||||
|
.zr.redirect_ip_v4.s_addr),
|
||||||
|
(ecom_eval->val+2), 4);
|
||||||
|
api_action->u.zr.duplicate =
|
||||||
|
ecom_eval->val[7];
|
||||||
|
api_action_redirect_ip = api_action;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ecom_eval->val[0] !=
|
if (ecom_eval->val[0] !=
|
||||||
(char)ECOMMUNITY_ENCODE_TRANS_EXP)
|
(char)ECOMMUNITY_ENCODE_TRANS_EXP)
|
||||||
|
Loading…
Reference in New Issue
Block a user