OSPFd: Update Segment Routing PR following review

Following various review, following files have been modfied:

 - All: Change u_intXX_t typedef to standard uintXX_t types
 - doc/OSPF-SR.rst: Update doc in particular the Linux Kernel configuration
section
 - doc/ospfd.texi: Update CLI
 - ospfd/ospf_dump.[c,h]: Add new 'debug ospf sr' when performing 'sh run'
 - ospfd/ospf_ext.[c, h]: Various bug corrections notably to handle flooding of
Extended Prefix at startup. iFix TLVs size for LAN Adjacency.
Update Licence as per Community.md
 - ospfd/ospf_opaque.c: Add proper termination function call to remove MPLS entries
 - ospfd/ospf_ri.[c,h]: Bug corrections
 - ospfd/ospf_sr.[c,h]: Various bug corrections, notably to determine the nexthop
SR Node. Add support to 'no-php-flag'.
Update Licence as per Community.md
 - ospfd/ospfd.c: Add call to 'ospf_opaque_term()'

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
This commit is contained in:
Olivier Dugeon 2018-01-29 17:58:53 +01:00
parent 93f0a26e19
commit 7743f2f8c0
12 changed files with 984 additions and 790 deletions

View file

@ -1,56 +1,61 @@
OSPF Segment Routing
====================
This is an EXPERIMENTAL support of draft draft-ietf-ospf-segment-routing-extensions-24.
This is an EXPERIMENTAL support of draft
`draft-ietf-ospf-segment-routing-extensions-24`.
DON'T use it for production network.
Implementation details
----------------------
### Concepts
Concepts
~~~~~~~~
Segment Routing used 3 differents OPAQUE LSA in OSPF to carry the various
information:
- Router Information: flood the Segment Routing capabilities of the node.
This include the supported algorithms, the Segment Routing Global Block
(SRGB) and the Maximum Stack Depth (MSD).
- Extended Link: flood the Adjaceny and Lan Adjacency Segment Identifier
- Extended Prefix: flood the Prefix Segment Identifier
* **Router Information:** flood the Segment Routing capabilities of the node.
This include the supported algorithms, the Segment Routing Global Block
(SRGB) and the Maximum Stack Depth (MSD).
* **Extended Link:** flood the Adjaceny and Lan Adjacency Segment Identifier
* **Extended Prefix:** flood the Prefix Segment Identifier
The implementation follow previous TE and Router Information code. It used the
OPAQUE LSA functions define in ospf_opaque.[c,h] as well as the OSPF API. This
The implementation follow previous TE and Router Information codes. It used the
OPAQUE LSA functions defined in ospf_opaque.[c,h] as well as the OSPF API. This
latter is mandatory for the implementation as it provides the Callback to
Segment Routing functions (see below) when an Extended Link / Prefix or Router
Information is received.
Information LSA s are received.
### Overview
Overview
~~~~~~~~
Following files where modified or added:
- ospd_ri.[c,h] have been modified to add the new TLVs for Segment Routing.
- ospf_ext.[c,h] implement RFC7684 as base support of Extended Link and Prefix
Opaque LSA.
- ospf_sr.[c,h] implement the earth of Segment Routing. It adds a new Segment
Routing database to manage Segment Identifiers per Link and Prefix and
Segment Routing enable node, Callback functions to process incoming LSA and
install MPLS FIB entry through Zebra.
* ospd_ri.[c,h] have been modified to add the new TLVs for Segment Routing.
* ospf_ext.[c,h] implement RFC7684 as base support of Extended Link and Prefix
Opaque LSA.
* ospf_sr.[c,h] implement the earth of Segment Routing. It adds a new Segment
Routing database to manage Segment Identifiers per Link and Prefix and
Segment Routing enable node, Callback functions to process incoming LSA and
install MPLS FIB entry through Zebra.
The figure below shows the relation between the various files:
- ospf_sr.c centralized all the Segment Routing processing. It receives Opaque
LSA Router Information (4.0.0.0) from ospf_ri.c and Extended Prefix
(7.0.0.X) Link (8.0.0.X) from ospf_ext.c. Once received, it parse TLVs and
SubTLVs and store information in SRDB (which is defined in ospf_sr.h). For
each received LSA, NHLFE is computed and send to Zebra to add/remove new
MPLS labels entries and FEC. New CLI configurations are also centralized in
ospf_sr.c. This CLI will trigger the flooding of new LSA Router Information
(4.0.0.0), Extended Prefix (7.0.0.X) and Link (8.0.0.X) by ospf_ri.c,
respectively ospf_ext.c.
- ospf_ri.c send back to ospf_sr.c received Router Information LSA and update
Self Router Information LSA with paramters provided by ospf_sr.c i.e. SRGB
and MSD. It use ospf_opaque.c functions to send/received these Opaque LSAs.
- ospf_ext.c send back to ospf_sr.c received Extended Prefix and Link Opaque
LSA and send self Extended Prefix and Link Opaque LSA through ospf_opaque.c
functions.
* ospf_sr.c centralized all the Segment Routing processing. It receives Opaque
LSA Router Information (4.0.0.0) from ospf_ri.c and Extended Prefix
(7.0.0.X) Link (8.0.0.X) from ospf_ext.c. Once received, it parse TLVs and
SubTLVs and store information in SRDB (which is defined in ospf_sr.h). For
each received LSA, NHLFE is computed and send to Zebra to add/remove new
MPLS labels entries and FEC. New CLI configurations are also centralized in
ospf_sr.c. This CLI will trigger the flooding of new LSA Router Information
(4.0.0.0), Extended Prefix (7.0.0.X) and Link (8.0.0.X) by ospf_ri.c,
respectively ospf_ext.c.
* ospf_ri.c send back to ospf_sr.c received Router Information LSA and update
Self Router Information LSA with paramters provided by ospf_sr.c i.e. SRGB
and MSD. It use ospf_opaque.c functions to send/received these Opaque LSAs.
* ospf_ext.c send back to ospf_sr.c received Extended Prefix and Link Opaque
LSA and send self Extended Prefix and Link Opaque LSA through ospf_opaque.c
functions.
::
@ -85,69 +90,177 @@ The figure below shows the relation between the various files:
| |
+---------------+
Figure1: Overview of Segment Routing interaction
Figure 1: Overview of Segment Routing interaction
### Module interactions
Module interactions
~~~~~~~~~~~~~~~~~~~
To process incoming LSA, the code is based on the capability to call `hook()` functions when LSA are inserted or delete to / from the LSDB and the possibility to register particular treatment for Opaque LSA. The first point is provided by the OSPF API feature and the second by the Opaque implementation itself. Indeed, it is possible to register callback function for a given Opaque LSA ID (see `ospf_register_opaque_functab()` function defined in `ospf_opaque.c`). Each time a new LSA is added to the LSDB, the `new_lsa_hook()` function previously register for this LSA type is called. For Opaque LSA it is the `ospf_opaque_lsa_install_hook()`. For deletion, it is `ospf_opaque_lsa_delete_hook()`.
To process incoming LSA, the code is based on the capability to call `hook()`
functions when LSA are inserted or delete to / from the LSDB and the
possibility to register particular treatment for Opaque LSA. The first point
is provided by the OSPF API feature and the second by the Opaque implementation
itself. Indeed, it is possible to register callback function for a given Opaque
LSA ID (see `ospf_register_opaque_functab()` function defined in
`ospf_opaque.c`). Each time a new LSA is added to the LSDB, the
`new_lsa_hook()` function previously register for this LSA type is called. For
Opaque LSA it is the `ospf_opaque_lsa_install_hook()`. For deletion, it is
`ospf_opaque_lsa_delete_hook()`.
Note that incoming LSA which is already present in the LSDB will be inserted after the old instance of this LSA remove from the LSDB. Thus, after the first time, each incoming LSA will trigger a `delete` following by an `install`. This is not very helpfull to handle real LSA deletion. In fact, LSA deletion is done by Flushing LSA i.e. flood LSA after seting its age to MAX_AGE. Then, a garbage function has the role to remove all LSA with `age == MAX_AGE` in the LSDB. So, to handle LSA Flush, the best is to look to the LSA age to determine if it is an installation or a future deletion i.e. the flushed LSA is first store in the LSDB with MAX_AGE waiting for the garbage collector function.
Note that incoming LSA which is already present in the LSDB will be inserted
after the old instance of this LSA remove from the LSDB. Thus, after the first
time, each incoming LSA will trigger a `delete` following by an `install`. This
is not very helpfull to handle real LSA deletion. In fact, LSA deletion is done
by Flushing LSA i.e. flood LSA after seting its age to MAX_AGE. Then, a garbage
function has the role to remove all LSA with `age == MAX_AGE` in the LSDB. So,
to handle LSA Flush, the best is to look to the LSA age to determine if it is
an installation or a future deletion i.e. the flushed LSA is first store in the
LSDB with MAX_AGE waiting for the garbage collector function.
#### Router Information LSAs
Router Information LSAs
^^^^^^^^^^^^^^^^^^^^^^^
To activate Segment Routing, new CLI command `segment-routing on` has been introduced. When this command is activated, function `ospf_router_info_update_sr()` is called to indicate to Router Information process that Segment Routing TLVs must be flood. Same function is called to modify the Segment Routing Global Block (SRGB) and Maximum Stack Depth (MSD) TLV. Only Shortest Path First (SPF) Algorithm is supported, so no possiblity to modify this TLV is offer by the code.
To activate Segment Routing, new CLI command `segment-routing on` has been
introduced. When this command is activated, function
`ospf_router_info_update_sr()` is called to indicate to Router Information
process that Segment Routing TLVs must be flood. Same function is called to
modify the Segment Routing Global Block (SRGB) and Maximum Stack Depth (MSD)
TLV. Only Shortest Path First (SPF) Algorithm is supported, so no possiblity
to modify this TLV is offer by the code.
When Opaque LSA Tyep 4 i.e. Router Information are stored in LSDB, function `ospf_opaque_lsa_install_hook()` will call the previously registered function `ospf_router_info_lsa_update()`. In turn, the function will simply trigger `ospf_sr_ri_lsa_update()` or `ospf_sr_ri_lsa_delete` in function of the LSA age. Before, it verifies that the LSA Opaque Type is 4 (Router Information). Self Opaque LSA are not send back to the Segment Routing functions as information are already stored.
When Opaque LSA Tyep 4 i.e. Router Information are stored in LSDB, function
`ospf_opaque_lsa_install_hook()` will call the previously registered function
`ospf_router_info_lsa_update()`. In turn, the function will simply trigger
`ospf_sr_ri_lsa_update()` or `ospf_sr_ri_lsa_delete` in function of the LSA
age. Before, it verifies that the LSA Opaque Type is 4 (Router Information).
Self Opaque LSA are not send back to the Segment Routing functions as
information are already stored.
#### Extended Link Prefix LSAs
Extended Link Prefix LSAs
^^^^^^^^^^^^^^^^^^^^^^^^^
Like for Router Information, Segment Routing is activate at the Extended Link/Prefix level with new `segment-routing on` command. This trigger automtically the flooding of Extended Link LSA for all ospf interface where adjacency is full. For Extended Prefix LSA, the new CLI command `segment-routing prefix ...` will trigger the flooding of Prefix SID TLV/SubTLVs.
Like for Router Information, Segment Routing is activate at the Extended
Link/Prefix level with new `segment-routing on` command. This trigger
automtically the flooding of Extended Link LSA for all ospf interface where
adjacency is full. For Extended Prefix LSA, the new CLI command
`segment-routing prefix ...` will trigger the flooding of Prefix SID
TLV/SubTLVs.
When Opaque LSA Type 7 i.e. Extended Prefix and Type 8 i.e. Extended Link are store in the LSDB, `ospf_ext_pref_update_lsa()` respectively `ospf_ext_link_update_lsa()` are called like for Router Information LSA. In turn, they respectively trigger `ospf_sr_ext_prefix_lsa_update()` / `ospf_sr_ext_link_lsa_update()` or `ospf_sr_ext_prefix_lsa_delete()` / `ospf_sr_ext_link_lsa_delete()` if the LSA age is equel to MAX_AGE.
When Opaque LSA Type 7 i.e. Extended Prefix and Type 8 i.e. Extended Link are
store in the LSDB, `ospf_ext_pref_update_lsa()` respectively
`ospf_ext_link_update_lsa()` are called like for Router Information LSA. In
turn, they respectively trigger `ospf_sr_ext_prefix_lsa_update()` /
`ospf_sr_ext_link_lsa_update()` or `ospf_sr_ext_prefix_lsa_delete()` /
`ospf_sr_ext_link_lsa_delete()` if the LSA age is equal to MAX_AGE.
#### Zebra
Zebra
^^^^^
When a new MPLS entry of new Forwarding Equivalent Class (FEC) must be add or delete in the data plane, `add_sid_nhlfe()` respectively `del_sid_nhlfe()` are called. Once check the validity of labels, they send to ZEBRA layer a new labels through `ZEBRA_MPLS_LABELS_ADD` command, respectively `ZEBRA_MPLS_LABELS_DELETE` command for deletion. This is completed by a new labelled route through `ZEBRA_ROUTE_ADD` command, respectively `ZEBRA_ROUTE_DELETE` command.
When a new MPLS entry or new Forwarding Equivalent Class (FEC) must be added or
deleted in the data plane, `add_sid_nhlfe()` respectively `del_sid_nhlfe()` are
called. Once check the validity of labels, they are send to ZEBRA layer through
`ZEBRA_MPLS_LABELS_ADD` command, respectively `ZEBRA_MPLS_LABELS_DELETE`
command for deletion. This is completed by a new labelled route through
`ZEBRA_ROUTE_ADD` command, respectively `ZEBRA_ROUTE_DELETE` command.
Configuration
-------------
Linux Kernel
~~~~~~~~~~~~
In order to use OSPF Segment Routing, you must setup MPLS data plane. Up to
know, only Linux Kernel version >= 4.5 is supported.
First, the MPLS modules aren't loaded by default, so you'll need to load them
yourself:
::
modprobe mpls_router
modprobe mpls_gso
modprobe mpls_iptunnel
Then, you must activate MPLS on the interface you would used:
::
sysctl -w net.mpls.conf.enp0s9.input=1
sysctl -w net.mpls.conf.lo.input=1
sysctl -w net.mpls.platform_labels=1048575
The last line fix the maximum MPLS label value.
Once OSPFd start with Segment Routing, you could check that MPLS routes are
enable with:
::
ip -M route
ip route
The first command show the MPLS LFIB table while the second show the FIB
table which contains route with MPLS label encapsulation.
If you disable Penultimate Hop Popping with the `no-php-flag` (see below), you
MUST check that RP filter is not enable for the interface you intend to use,
especially the `lo` one. For that purpose, disable RP filtering with:
::
systcl -w net.ipv4.conf.all.rp_filter=0
sysctl -w net.ipv4.conf.lo.rp_filter=0
OSPFd
~~~~~
Here it is a simple example of configuration to enable Segment Routing. Note
that ``opaque capability`` must be set to activate Opaque LSA prior to Segment
that `opaque capability` and `router information` must be set to activate
Opaque LSA prior to Segment
Routing.
::
router ospf
ospf router-id 192.168.1.11
capability opaque
mpls-te on
mpls-te router-address 192.168.1.11
router-info area 0.0.0.0
segment-routing on
segment-routing global-block 10000 19999
segment-routing node-msd 8
segment-routing prefix 192.168.1.11/32 index 1100
router ospf
ospf router-id 192.168.1.11
capability opaque
mpls-te on
mpls-te router-address 192.168.1.11
router-info area 0.0.0.0
segment-routing on
segment-routing global-block 10000 19999
segment-routing node-msd 8
segment-routing prefix 192.168.1.11/32 index 1100
The first segment-routing statement enable it. The Second one set the SRGB,
third line the MSD and finally, set the Prefix SID index for tha given prefix.
third line the MSD and finally, set the Prefix SID index for a given prefix.
Note that only prefix of Loopback interface could be configured with a Prefix
SID.
SID. It is possible to add `no-php-flag` at the end of the prefix command to
disbale Penultimate Hop Popping. This advertises peers that they MUST NOT pop
the MPLS label prior to sending the packet.
Known limitations
-----------------
- Runs only within default VRF
- Only single Area is supported. ABR is not yet supported
- Only SPF algorithm is supported
- Extended Prefix Range is not supported
- MPLS table are not flush at startup. Thus, restarting zebra process is mandatory to remove old MPLS entries in the data plane after a crash of ospfd daemon.
* Runs only within default VRF
* Only single Area is supported. ABR is not yet supported
* Only SPF algorithm is supported
* Extended Prefix Range is not supported
* MPLS table are not flush at startup. Thus, restarting zebra process is
mandatory to remove old MPLS entries in the data plane after a crash of
ospfd daemon
* Due to a bug in OSPF Opaque, LSA are not flood when enable Segment Routing
through CLI once OSPFd started. You must configure Segment Routing within
configuration file before launching OSPFd
* With NO Penultimate Hop Popping, it is not possible to express a Segment
Path with an Adjacency SID due to the impossibility for the Linux Kernel to
perform double POP instruction.
Credits
-------
* Author: Anselme Sawadogo <anselmesawadogo@gmail.com>
* Author: Olivier Dugeon <olivier.dugeon@orange.com>
* Copyright (C) 2016 - 2018 Orange Labs http://www.orange.com
* Author: Anselme Sawadogo <anselmesawadogo@gmail.com>
* Author: Olivier Dugeon <olivier.dugeon@orange.com>
* Copyright (C) 2016 - 2018 Orange Labs http://www.orange.com
This work has been performed in the framework of the H2020-ICT-2014
project 5GEx (Grant Agreement no. 671636), which is partially funded

View file

@ -729,7 +729,7 @@ Show Router Capabilities PCE parameters.
@section Segment Routing
This is an EXPERIMENTAL support of Segment Routing as per draft
draft-ietf-ospf-segment-routing-extensions-24i for MPLS dataplane.
draft-ietf-ospf-segment-routing-extensions-24.txt for MPLS dataplane.
@deffn {OSPF Command} {segment-routing on} {}
@deffnx {OSPF Command} {no segment-routing} {}
@ -746,15 +746,17 @@ label in the MPLS FIB.
@deffn {OSPF Command} {segment-routing node-msd (1-16)} {}
@deffnx {OSPF Command} {no segment-routing node-msd} {}
Fix the Maximum Stack Depth supported by the router. The value depend of the
Fix the Maximum Stack Depth supported by the router. The value depend of the
MPLS dataplane. E.g. for Linux kernel, since version 4.13 it is 32.
@end deffn
@deffn {OSPF Command} {segment-routing prefix A.B.C.D/M index (0-65535)} {}
@deffnx {OSPF Command} {segment-routing prefix A.B.C.D/M index (0-65535) no-php-flag} {}
@deffnx {OSPF Command} {no segment-routing prefix A.B.C.D/M} {}
Set the Segment Rounting index for the specifyed prefix. Note
that, only prefix with /32 corresponding to a loopback interface are
currently supported.
that, only prefix with /32 corresponding to a loopback interface are
currently supported. The 'no-php-flag' means NO Penultimate Hop Popping that
allows SR node to request to its neighbor to not pop the label.
@end deffn
@deffn {Command} {show ip ospf database segment-routing} {}

View file

@ -1788,6 +1788,18 @@ static int config_write_debug(struct vty *vty)
write = 1;
}
/* debug ospf te */
if (IS_CONF_DEBUG_OSPF(te, TE) == OSPF_DEBUG_TE) {
vty_out(vty, "debug ospf%s te\n", str);
write = 1;
}
/* debug ospf sr */
if (IS_CONF_DEBUG_OSPF(sr, SR) == OSPF_DEBUG_SR) {
vty_out(vty, "debug ospf%s sr\n", str);
write = 1;
}
return write;
}

View file

@ -94,15 +94,15 @@
/* Macro for checking debug option. */
#define IS_DEBUG_OSPF_PACKET(a, b) (term_debug_ospf_packet[a] & OSPF_DEBUG_##b)
#define IS_DEBUG_OSPF(a, b) (term_debug_ospf_##a & OSPF_DEBUG_##b)
#define IS_DEBUG_OSPF_EVENT IS_DEBUG_OSPF(event,EVENT)
#define IS_DEBUG_OSPF_EVENT IS_DEBUG_OSPF(event, EVENT)
#define IS_DEBUG_OSPF_NSSA IS_DEBUG_OSPF(nssa,NSSA)
#define IS_DEBUG_OSPF_NSSA IS_DEBUG_OSPF(nssa, NSSA)
#define IS_DEBUG_OSPF_TE IS_DEBUG_OSPF(te,TE)
#define IS_DEBUG_OSPF_TE IS_DEBUG_OSPF(te, TE)
#define IS_DEBUG_OSPF_EXT IS_DEBUG_OSPF(ext,EXT)
#define IS_DEBUG_OSPF_EXT IS_DEBUG_OSPF(ext, EXT)
#define IS_DEBUG_OSPF_SR IS_DEBUG_OSPF(sr,SR)
#define IS_DEBUG_OSPF_SR IS_DEBUG_OSPF(sr, SR)
#define IS_CONF_DEBUG_OSPF_PACKET(a, b) \
(conf_debug_ospf_packet[a] & OSPF_DEBUG_##b)

File diff suppressed because it is too large Load diff

View file

@ -4,27 +4,24 @@
*
* Module name: Extended Prefix/Link Opaque LSA header definition
*
* Author: Anselme Sawadogo <anselmesawadogo@gmail.com>
* Author: Olivier Dugeon <olivier.dugeon@orange.com>
* Author: Anselme Sawadogo <anselmesawadogo@gmail.com>
*
* Copyright (C) 2016 - 2017 Orange Labs http://www.orange.com
* Copyright (C) 2016 - 2018 Orange Labs http://www.orange.com
*
* This file is part of FRR.
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* FRR is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* FRR is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FRR; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
* You should have received a copy of the GNU General Public License along
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _FRR_OSPF_EXT_PREF_H_
@ -42,7 +39,7 @@
*
*
* Type: IANA has assigned '7' for Extended Prefix Opaque LSA
* and '8' for Extended Link Opaque LSA
* and '8' for Extended Link Opaque LSA
* Instance: User may select arbitrary 24-bit values to identify
* different instances of Extended Prefix/Link Opaque LSA
*
@ -71,7 +68,7 @@
/* Global use constant numbers */
#define MAX_LEGAL_EXT_INSTANCE_NUM (0xffff)
#define MAX_LEGAL_EXT_INSTANCE_NUM (0xffff)
#define LEGAL_EXT_INSTANCE_RANGE(i) (0 <= (i) && (i) <= 0xffff)
/* Flags to manage Extended Link/Prefix Opaque LSA */
@ -94,8 +91,10 @@
#define EXT_TLV_PREF_ROUTE_AS_EXT 5
#define EXT_TLV_PREF_ROUTE_NSSA_EXT 7
/* Extended Prefix and Extended Prefix Range TLVs'
* Address family flag for IPv4 */
/*
* Extended Prefix and Extended Prefix Range TLVs'
* Address family flag for IPv4
*/
#define EXT_TLV_PREF_AF_IPV4 0
/* Extended Prefix TLV Flags */
@ -146,8 +145,10 @@ struct ospf_ext_lp {
/* Flags to manage this Extended Prefix/Link Opaque LSA */
uint32_t flags;
/* Scope is area Opaque Type 10 or AS Opaque LSA Type 11 for
* Extended Prefix and area Opaque Type 10 for Extended Link */
/*
* Scope is area Opaque Type 10 or AS Opaque LSA Type 11 for
* Extended Prefix and area Opaque Type 10 for Extended Link
*/
uint8_t scope;
/* area pointer if flooding is Type 10 Null if flooding is AS scope */
@ -190,7 +191,9 @@ struct ext_itf {
/* Prototypes. */
extern int ospf_ext_init(void);
extern void ospf_ext_term(void);
extern void ospf_ext_update_sr(bool);
extern int ospf_ext_schedule_prefix_index(struct interface *, uint32_t,
struct prefix_ipv4 *);
extern void ospf_ext_update_sr(bool enable);
extern int ospf_ext_schedule_prefix_index(struct interface *ifp,
uint32_t index,
struct prefix_ipv4 *p,
uint8_t flags);
#endif /* _FRR_OSPF_EXT_PREF_H_ */

View file

@ -93,7 +93,6 @@ void ospf_opaque_init(void)
if (ospf_router_info_init() != 0)
exit(1);
/* Force Extended Prefix/Link to Type 10 */
if (ospf_ext_init() != 0)
exit(1);

View file

@ -69,7 +69,10 @@ struct ospf_pce_info {
struct ri_pce_subtlv_cap_flag pce_cap_flag;
};
/* Store Router Information Segment Routing TLV and SubTLV in network byte order. */
/*
* Store Router Information Segment Routing TLV and SubTLV
* in network byte order
*/
struct ospf_ri_sr_info {
bool enabled;
/* Algorithms supported by the node */
@ -195,23 +198,6 @@ static int ospf_router_info_register(u_int8_t scope)
return rc;
}
static int ospf_router_info_unregister()
{
if ((OspfRI.scope != OSPF_OPAQUE_AS_LSA)
&& (OspfRI.scope != OSPF_OPAQUE_AREA_LSA)) {
zlog_warn(
"Unable to unregister Router Info functions: Wrong scope!");
return -1;
}
ospf_delete_opaque_functab(OspfRI.scope,
OPAQUE_TYPE_ROUTER_INFORMATION_LSA);
OspfRI.registered = 0;
return 0;
}
void ospf_router_info_term(void)
{
@ -220,8 +206,6 @@ void ospf_router_info_term(void)
OspfRI.enabled = false;
ospf_router_info_unregister();
return;
}
@ -235,6 +219,7 @@ static void del_pce_info(void *val)
struct scope_info ospf_router_info_get_flooding_scope(void)
{
struct scope_info flooding_scope;
if (OspfRI.scope == OSPF_OPAQUE_AS_LSA) {
flooding_scope.scope = OSPF_OPAQUE_AS_LSA;
flooding_scope.area_id.s_addr = 0;
@ -454,7 +439,6 @@ static void set_sr_algorithm(uint8_t algo)
TLV_TYPE(OspfRI.sr_info.algo) = htons(RI_SR_TLV_SR_ALGORITHM);
TLV_LEN(OspfRI.sr_info.algo) = htons(sizeof(uint8_t));
return;
}
/* unset Aglogithm SubTLV */
@ -468,7 +452,6 @@ static void unset_sr_algorithm(uint8_t algo)
TLV_TYPE(OspfRI.sr_info.algo) = htons(0);
TLV_LEN(OspfRI.sr_info.algo) = htons(0);
return;
}
/* Segment Routing Global Block SubTLV - section 3.2 */
@ -485,11 +468,10 @@ static void set_sr_sid_label_range(struct sr_srgb srgb)
TLV_LEN(OspfRI.sr_info.range.lower) = htons(SID_RANGE_LABEL_LENGTH);
OspfRI.sr_info.range.lower.value = htonl(SET_LABEL(srgb.lower_bound));
return;
}
/* Unset this SRGB SubTLV */
static void unset_sr_sid_label_range()
static void unset_sr_sid_label_range(void)
{
TLV_TYPE(OspfRI.sr_info.range) = htons(0);
@ -497,7 +479,6 @@ static void unset_sr_sid_label_range()
TLV_TYPE(OspfRI.sr_info.range.lower) = htons(0);
TLV_LEN(OspfRI.sr_info.range.lower) = htons(0);
return;
}
/* Set Maximum Stack Depth for this router */
@ -507,16 +488,14 @@ static void set_sr_node_msd(uint8_t msd)
TLV_LEN(OspfRI.sr_info.msd) = htons(sizeof(uint32_t));
OspfRI.sr_info.msd.value = msd;
return;
}
/* Unset this router MSD */
static void unset_sr_node_msd()
static void unset_sr_node_msd(void)
{
TLV_TYPE(OspfRI.sr_info.msd) = htons(0);
TLV_LEN(OspfRI.sr_info.msd) = htons(0);
return;
}
static void unset_param(struct tlv_header *tlv)
@ -1041,7 +1020,7 @@ static int ospf_router_info_lsa_update(struct ospf_lsa *lsa)
/* Sanity Check */
if (lsa == NULL) {
zlog_warn("OSPF-RI (ospf_router_info_lsa_update): Abort! LSA is NULL");
zlog_warn("OSPF-RI (%s): Abort! LSA is NULL", __func__);
return -1;
}
@ -1050,8 +1029,8 @@ static int ospf_router_info_lsa_update(struct ospf_lsa *lsa)
return 0;
/* Process only Router Information LSA */
if (GET_OPAQUE_TYPE(
ntohl(lsa->data->id.s_addr)) != OPAQUE_TYPE_ROUTER_INFORMATION_LSA)
if (GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr)) !=
OPAQUE_TYPE_ROUTER_INFORMATION_LSA)
return 0;
/* Check if Router Info & Segment Routing are enable */
@ -1239,6 +1218,7 @@ static uint16_t show_vty_sr_algorithm(struct vty *vty, struct tlv_header *tlvh)
struct ri_sr_tlv_sr_algorithm *algo =
(struct ri_sr_tlv_sr_algorithm *)tlvh;
int i;
if (vty != NULL) {
vty_out(vty, " Segment Routing Algorithm TLV:\n");
for (i = 0; i < ntohs(algo->header.length); i++) {

View file

@ -87,7 +87,7 @@ struct ri_tlv_router_cap {
#define RI_STUB_SUPPORT 0x20000000
#define RI_TE_SUPPORT 0x10000000
#define RI_P2P_OVER_LAN 0x08000000
#define RI_TE_EXPERIMENTAL 0x04000000
#define RI_TE_EXPERIMENTA 0x04000000
#define RI_TLV_LENGTH 4
@ -177,6 +177,7 @@ struct scope_info {
extern int ospf_router_info_init(void);
extern void ospf_router_info_term(void);
extern int ospf_router_info_enable(void);
extern void ospf_router_info_update_sr(bool, struct sr_srgb, uint8_t);
extern void ospf_router_info_update_sr(bool enable, struct sr_srgb srgb,
uint8_t msd);
extern struct scope_info ospf_router_info_get_flooding_scope(void);
#endif /* _ZEBRA_OSPF_ROUTER_INFO_H */

File diff suppressed because it is too large Load diff

View file

@ -7,24 +7,21 @@
* Author: Olivier Dugeon <olivier.dugeon@orange.com>
* Author: Anselme Sawadogo <anselmesawadogo@gmail.com>
*
* Copyright (C) 2016 - 2017 Orange Labs http://www.orange.com
* Copyright (C) 2016 - 2018 Orange Labs http://www.orange.com
*
* This file is part of FRR.
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* FRR is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* FRR is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FRR; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
* You should have received a copy of the GNU General Public License along
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _FRR_OSPF_SR_H
@ -43,9 +40,9 @@
#define SET_LABEL(label) ((label << 8) & SET_LABEL_MASK)
#define GET_LABEL(label) ((label >> 8) & GET_LABEL_MASK)
/* Label range for Adj-SID attribution purpose. See ospf_ext.c */
#define ADJ_SID_MIN 50000
#define ADJ_SID_MAX 51000
/* Label range for Adj-SID attribution purpose. Start just right after SRGB */
#define ADJ_SID_MIN MPLS_DEFAULT_MAX_SRGB_LABEL
#define ADJ_SID_MAX (MPLS_DEFAULT_MAX_SRGB_LABEL + 1000)
#define OSPF_SR_DEFAULT_METRIC 1
@ -259,7 +256,7 @@ struct sr_link {
uint32_t instance;
/* Flags to manage this link parameters. */
uint32_t flags[2];
uint8_t flags[2];
/* Segment Routing ID */
uint32_t sid[2];
@ -279,7 +276,7 @@ struct sr_prefix {
uint32_t instance;
/* Flags to manage this prefix parameters. */
uint32_t flags;
uint8_t flags;
/* Segment Routing ID */
uint32_t sid;
@ -291,8 +288,10 @@ struct sr_prefix {
/* Back pointer to SR Node which advertise this Prefix */
struct sr_node *srn;
/* Pointer to SR Node which is the next hop for this Prefix
* or NULL if next hop is the destination of the prefix */
/*
* Pointer to SR Node which is the next hop for this Prefix
* or NULL if next hop is the destination of the prefix
*/
struct sr_node *nexthop;
};
@ -303,13 +302,14 @@ extern void ospf_sr_term(void);
/* Segment Routing LSA update & delete functions */
extern void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa);
extern void ospf_sr_ri_lsa_delete(struct ospf_lsa *lsa);
extern void ospf_sr_ext_link_lsa_update(struct ospf_lsa *);
extern void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *);
extern void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *);
extern void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *);
extern void ospf_sr_ext_link_lsa_update(struct ospf_lsa *lsa);
extern void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *lsa);
extern void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa);
extern void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *lsa);
/* Segment Routing configuration functions */
extern uint32_t get_ext_link_label_value(void);
extern void ospf_sr_config_write_router(struct vty *);
extern void ospf_sr_config_write_router(struct vty *vty);
extern void ospf_sr_update_prefix(struct interface *ifp, struct prefix *p);
/* Segment Routing re-routing function */
extern void ospf_sr_update_timer_add(struct ospf *);
extern void ospf_sr_update_timer_add(struct ospf *ospf);
#endif /* _FRR_OSPF_SR_H */

View file

@ -766,6 +766,8 @@ static void ospf_finish_final(struct ospf *ospf)
if (!CHECK_FLAG(om->options, OSPF_MASTER_SHUTDOWN))
instance = ospf->instance;
ospf_opaque_term();
ospf_delete(ospf);
if (ospf->name) {