Commit Graph

439 Commits

Author SHA1 Message Date
Donatas Abraitis
fd283bd250 bgpd: Use route_map_result_t for route_map_apply() as return type
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-20 10:45:02 +03:00
Donatas Abraitis
1bd367634e bgpd: Treat as withdraw if we receive as path with AS_SET / AS_CONFED_SET
For now, only if the knob is enabled. Later this gonna be (most likely) removed
and routes with AS_SET / AS_CONFED_SET will be denied by default.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-15 21:41:15 +03:00
Donatas Abraitis
adc1c459b1 bgpd: OTC attribute should be treated as withdrawal
According to RFC9234:

An UPDATE message with a malformed OTC Attribute SHALL be handled
   using the approach of "treat-as-withdraw".

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-14 23:44:27 +03:00
Donatas Abraitis
70632160e9 bgpd: Reuse ipv4_martian() when validating BGP next-hop
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-01 23:38:14 +03:00
Lou Berger
613025ef10
Merge pull request #11093 from donaldsharp/allow_martians
Allow martians
2022-06-28 10:38:57 -04:00
Donatas Abraitis
f646c17a43
Merge pull request #11426 from error2407/open_policy
bgpd: Add RFC9234 implementation
2022-06-27 09:57:29 +03:00
Donald Sharp
8666265e2e bgpd: Add bgp allow-martian-nexthop command
The command `debug bgp allow-martian` is not actually
a debug command it's a command that when entered allows
bgp to not reset a peering when a martian nexthop is
passed in the nlri.

Add the `bgp allow-martian-nexthop` command and allow it to be
used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-24 07:45:46 -04:00
Donatas Abraitis
fdfd1a6f40 bgpd: Drop duplicate label assignment
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-21 11:57:33 +03:00
Eugene Bogomazov
d864dd9eb1 bgpd: Add RFC9234 implementation
RFC9234 is a way to establish correct connection roles (Customer/
Provider, Peer or with RS) between bgp speakers. This patch:
- Add a new configuration/terminal option to set the appropriate local
role;
- Add a mechanism for checking used roles, implemented by exchanging
the corresponding capabilities in OPEN messages;
- Add strict mode to force other party to use this feature;
- Add basic support for a new transitive optional bgp attribute - OTC
(Only to Customer);
- Add logic for default setting OTC attribute and filtering routes with
this attribute by the edge speakers, if the appropriate conditions are
met;
- Add two test stands to check role negotiation and route filtering
during role usage.

Signed-off-by: Eugene Bogomazov <eb@qrator.net>
2022-06-17 13:14:46 +03:00
Russ White
b3a35b33c0
Merge pull request #11344 from opensourcerouting/feature/wrap_ipv4_unicast_valid
bgpd: Wrap IPV4_CLASS_DE into ipv4_unicast_valid() helper
2022-06-14 07:48:32 -04:00
Donatas Abraitis
e24a6977ee bgpd: Wrap IPV4_CLASS_DE into ipv4_unicast_valid() helper
Linux kernel allows (FreeBSD/OpenBSD too) using reserved class E IP ranges.

This is a preparation commit that ease the global switch to allow/deny
class E IP ranges in FRR.

https://datatracker.ietf.org/doc/html/draft-chen-ati-adaptive-ipv4-address-space

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-13 20:44:52 +03:00
Donatas Abraitis
0f05ea43b0 bgpd: Initialize attr->local_pref to the configured default value
When we use network/redistribute local_preference is configured inproperly
when using route-maps something like:

```
network 100.100.100.100/32 route-map rm1
network 100.100.100.200/32 route-map rm2

route-map rm1 permit 10
 set local-preference +10
route-map rm2 permit 10
 set local-preference -10
```

Before:
```
root@spine1-debian-11:~# vtysh -c 'show bgp ipv4 unicast 100.100.100.100/32 json' | jq '.paths[].locPrf'
10
root@spine1-debian-11:~# vtysh -c 'show bgp ipv4 unicast 100.100.100.200/32 json' | jq '.paths[].locPrf'
0
```

After:
```
root@spine1-debian-11:~# vtysh -c 'show bgp ipv4 unicast 100.100.100.100/32 json' | jq '.paths[].locPrf'
110
root@spine1-debian-11:~# vtysh -c 'show bgp ipv4 unicast 100.100.100.200/32 json' | jq '.paths[].locPrf'
90
```

Set local-preference as the default value configured per BGP instance, but
do not set LOCAL_PREF flag by default.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-06 10:28:50 +03:00
Donatas Abraitis
ef013a6985
Merge pull request #11194 from donaldsharp/untrusted
Some more Coverity issues solved
2022-05-13 14:43:11 +03:00
Donald Sharp
d87c526b1b bgpd: Assign large enough data structure for coverity to be happy
When implementing the bgp_packet_mpunreach_prefix a uint8_t array
of 3 bytes was created and then assigned to a label type, which
is 4 bytes and then various pointer work is done on it.  Eventually
coverity is complaining that the 3 -vs- 4 bytes is not enough
to properly dereference it.  Just make the uint8_t 4 bytes
and be done with it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-12 16:47:05 -04:00
Donatas Abraitis
6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
Donald Sharp
617975d114 bgpd: Ensure pkt_afi and pkt_safi are not used uninited in some cases
The compiler is, rightly, pointing out that in some cases it is
possible that the pkt_afi and pkt_safi values are not properly
set and could result in a use before initialized.  I do not
actually belive that this is possible, but let's make the compiler
happy.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-27 08:06:22 -04:00
Donald Sharp
544be97911 *: Fix spelling of strucutre
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:19:37 -04:00
Donatas Abraitis
b17d5444f4 bgpd: Pass non-transitive ext-communities between Route Server and RS clients
https://datatracker.ietf.org/doc/html/rfc7947#section-2.2

Optional recognized and unrecognized BGP attributes,
   whether transitive or non-transitive, SHOULD NOT be updated by the
   route server (unless enforced by local IXP operator configuration)
   and SHOULD be passed on to other route server clients.

By default LB ext-community works with iBGP peers. When we receive a route
from eBGP peer, we can send LB ext-community to iBGP peers.

With this patch, allow sending LB ext-community to iBGP/eBGP peers if they
are set as RS clients.

FRR does not send non-transitive ext-communities to eBGP peers, but for
example GoBGP sends and if it's set as RS client, we should pass those attributes
towards another RS client.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-14 08:36:20 +03:00
Russ White
6a1dbeba2f
Merge pull request #11010 from opensourcerouting/feature/reuse_bgp_attr_set_community_for_flags
bgpd: Reuse bgp_attr_set_[el]community() for setting attribute flags
2022-04-13 14:54:30 -04:00
Russ White
a39df8492d
Merge pull request #11009 from opensourcerouting/fix/med_for_aggregate-address
bgpd: aggregate-address fixes
2022-04-13 14:53:14 -04:00
Donatas Abraitis
79288e4c12 bgpd: Convert bgp_attr_parse_ret_t to enum
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-12 22:13:55 +03:00
Donatas Abraitis
58cf5c088a bgpd: Reuse bgp_attr_set_ecommunity() for setting attribute flags
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-12 22:09:28 +03:00
Donatas Abraitis
9d34440bf8 bgpd: Reuse bgp_attr_set_[l]community() for setting attribute flags
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-12 22:09:28 +03:00
Donatas Abraitis
59136db5a7 bgpd: Send MED attribute when aggregate prefix is created
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-11 17:46:04 +03:00
Donatas Abraitis
c5fa4459f4 bgpd: Fix mixed print types for BGP_PREFIX_SID_SRV6_L3_SERVICE_SID_STRUCTURE_LENGTH
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-28 11:08:33 +03:00
Donald Sharp
5c111a25d4 bgpd: Fix possible insufficient stream data
When reading the BGP_PREFIX_SID_SRV6_L3_SERVICE_SID_STRUCTURE
it is possible that the length read in the packet is insufficiently
large enough to read a BGP_PREFIX_SID_SRV6_L3_SERVICE_SID_STRUCTURE.
Let's ensure that it is.

Fixes: #10860
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-25 07:44:55 -04:00
Donatas Abraitis
9a706b42fb bgpd: Reuse get/set helpers for attr->community
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-25 10:02:30 +02:00
Russ White
8f689a6e8d
Merge pull request #10546 from ton31337/fix/check_for_null_inside_unintern
bgpd: Check for NULL inside aspath_unintern()
2022-02-15 12:59:45 -05:00
Donatas Abraitis
cd03cf1644
Merge pull request #10540 from idryzhov/attr-extra-revert
revert recent bgp attr->extra changes
2022-02-10 14:46:49 +02:00
Donatas Abraitis
1bcf3a96de bgpd: Use get/set helpers for attr->lcommunity
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-10 11:04:03 +02:00
Igor Ryzhov
a2d3103a01 Revert "bgpd: Move out ipv6_ecommunity struct from attr to attr_extra"
This reverts commit 2703b7db19.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-02-10 12:00:30 +03:00
Igor Ryzhov
f363420261 Revert "bgpd: Free only subattributes, not the whole attr_extra pointer"
This reverts commit 0911206097.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-02-10 12:00:30 +03:00
Igor Ryzhov
d498917efd bgpd: remove bgp_attr_undup
bgp_attr_undup does the same thing as bgp_attr_flush – frees the
temporary data that might be allocated when applying a route-map. There
is no need to have two separate functions for that.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-02-10 01:43:37 +03:00
Donatas Abraitis
b7b3e63cc0 bgpd: Check for NULL inside aspath_unintern()
It's not always guarded, just check inside.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-09 16:41:14 +02:00
Donald Sharp
90798938b1
Merge pull request #10492 from ton31337/feature/pmsi_tnl_type_attr_extra
bgpd: Move attr->pmsi_tnl_type to attr->extra->pmsi_tnl_type
2022-02-08 14:13:04 -05:00
Donatas Abraitis
0911206097 bgpd: Free only subattributes, not the whole attr_extra pointer
Avoid use-after-free situation. Flush attr_extra structure only when flushing
all attributes, not just for unintern.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-05 10:01:57 +02:00
Donatas Abraitis
b53e67a389 bgpd: Use bgp_attr_[sg]et_ecommunity for struct ecommunity
This is an extra work before moving attr->ecommunity to attra_extra struct.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-04 15:56:20 +02:00
Russ White
acd2fe6bdd
Merge pull request #10428 from ton31337/fix/attr_extra_ipv6_ecommunity
bgpd: Move out ipv6_ecommunity struct from attr to attr_extra
2022-02-01 11:38:39 -05:00
Igor Ryzhov
3b216639d7
Merge pull request #10430 from ton31337/fix/addpath_maximum-prefix-out
bgpd: Add bgp_check_selected() helper and just consistency changes
2022-02-01 18:38:57 +03:00
Donatas Abraitis
be92fc9f1a bgpd: Convert bgp_addpath_encode_[tr]x() to bool from int
Rename addpath_encode[d] to addpath_capable to be consistent.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-01 13:31:16 +02:00
Iqra Siddiqui
761cc919fa bgpd: Fixing memcmp to avoid coverity issue
Description:
Replacing memcmp at certain places,
to avoid the coverity issues caused by it.

Co-authored-by: Kantesh Mundargi <kmundaragi@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2022-01-31 21:50:50 -08:00
Donatas Abraitis
2703b7db19 bgpd: Move out ipv6_ecommunity struct from attr to attr_extra
This is the initial work to move all non IPv4/IPv6 AFI related
attributes/structs to attr->extra to avoid unnecesarry allocations.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-26 21:52:40 +02:00
Russ White
ab6bff727a
Merge pull request #10235 from proelbtn/srv6-soft-reconf
SRv6 routes aren't inserted into data plane correctly with soft-reconfiguration
2022-01-11 11:03:34 -05:00
Donatas Abraitis
812a20dc57 bgpd: Deprecate DPA, ADVERTISER and RCID_PATH path attributes
rfc6938

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-06 17:10:31 +02:00
Rafael Zalamena
8bd0d3b1db bgpd: fix aggregate route AS Path attribute
Always free the locally allocated attribute not the one we are using for
return. This fixes a memory leak and a crash when AS Path is set with
route-map.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-12-21 10:48:18 -03:00
Ryoga Saito
3d1ae061a3 bgpd: delete NULL assignment in bgp_attr_hash_alloc
If soft-reconfiguration is enabled, bgp_adj_in_set will be called
from bgp_update and bgp_adj_in_set will call bgp_attr_intern to intern
attr pointer. If given attr isn't found in attrhash, hash_get will call
bgp_attr_hash_alloc to allocate new attr structure. In
bgp_attr_hash_alloc, NULL will be assigned to srv6_vpn field and
srv6_l3vpn field in origin attr pointer. attr->srv6_vpn and
attr->srv6_l3vpn are interned in bgp_attr_intern, so NULL assignment
isn't needed.

And, these fields are used later in bgp_update to set SRv6 information
to bgp_path_info. If bgp_attr_hash_alloc assign NULL to these fields,
SRv6 information will be lost and incorrect routes are inserted into
data-plane.

Signed-off-by: Ryoga Saito <contact@proelbtn.com>
2021-12-16 23:28:12 +09:00
Russ White
2075387e77
Merge pull request #9546 from proelbtn/add-support-for-perfix-sid-type-5
Add support for Prefix-SID (Type 5)
2021-09-21 11:36:53 -04:00
Kantesh Mundaragi
0789eb69e5 bgpd: VRF-Lite fix nexthop type
Description:
Change is intended for fixing the following issues related to vrf route leaking:

Routes with special nexthops i.e. blackhole/sink routes when imported,
are not programmed into the FIB and corresponding nexthop is set as 'inactive',
nexthop interface as 'unknown'.

While importing/leaking routes between VRFs, in case of special nexthop(ipv4/ipv6)
once bgp announces route(s) to zebra, nexthop type is incorrectly set as
NEXTHOP_TYPE_IPV6_IFINDEX/NEXTHOP_TYPE_IFINDEX
i.e. directly connected even though we are not able to resolve through an interface.
This leads to nexthop_active_check marking nexthop !NEXTHOP_FLAG_ACTIVE.
Unable to find the active nexthop(s), route is not programmed into the FIB.

Whenever BGP leaks routes, set the correct nexthop type, so that route gets resolved
and correctly programmed into the FIB, in the imported vrf.

Co-authored-by: Kantesh Mundaragi <kmundaragi@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2021-09-07 01:50:06 -07:00
Ryoga Saito
a1a5100851 bgpd: insert SID structure Sub-Sub-TLV
This patch enables frr to advertise SRv6 SID information with SID
structure Sub-Sub-TLV.

Signed-off-by: Ryoga Saito <contact@proelbtn.com>
2021-09-03 01:19:49 +00:00
Ryoga Saito
9299fd00e7 bgpd: introduce SID structure information
draft-ietf-bess-srv6-services-07 defines new SID structure Sub-Sub-TLV.
This patch adds SID structure information to bgp_attr_srv6_l3vpn. This
patch also defines default SID stucture used by following patches.

Signed-off-by: Ryoga Saito <contact@proelbtn.com>
2021-09-03 01:19:45 +00:00