2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2002-12-13 21:15:29 +01:00
|
|
|
/*
|
|
|
|
* This is an implementation of rfc2370.
|
|
|
|
* Copyright (C) 2001 KDD R&D Laboratories, Inc.
|
|
|
|
* http://www.kddlabs.co.jp/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ZEBRA_OSPF_OPAQUE_H
|
|
|
|
#define _ZEBRA_OSPF_OPAQUE_H
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
#include "vty.h"
|
2020-07-24 01:25:04 +02:00
|
|
|
#include <lib/json.h>
|
2005-05-06 23:37:42 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#define IS_OPAQUE_LSA(type) \
|
|
|
|
((type) == OSPF_OPAQUE_LINK_LSA || (type) == OSPF_OPAQUE_AREA_LSA \
|
|
|
|
|| (type) == OSPF_OPAQUE_AS_LSA)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Opaque LSA's link state ID is redefined as follows.
|
|
|
|
*
|
|
|
|
* 24 16 8 0
|
|
|
|
* +--------+--------+--------+--------+
|
|
|
|
* |tttttttt|........|........|........|
|
|
|
|
* +--------+--------+--------+--------+
|
|
|
|
* |<-Type->|<------- Opaque ID ------>|
|
|
|
|
*/
|
|
|
|
#define LSID_OPAQUE_TYPE_MASK 0xff000000 /* 8 bits */
|
|
|
|
#define LSID_OPAQUE_ID_MASK 0x00ffffff /* 24 bits */
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
#define GET_OPAQUE_TYPE(lsid) (((uint32_t)(lsid)&LSID_OPAQUE_TYPE_MASK) >> 24)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
#define GET_OPAQUE_ID(lsid) ((uint32_t)(lsid)&LSID_OPAQUE_ID_MASK)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
#define SET_OPAQUE_LSID(type, id) \
|
2017-09-07 15:58:18 +02:00
|
|
|
((((unsigned)(type) << 24) & LSID_OPAQUE_TYPE_MASK) \
|
|
|
|
| ((id)&LSID_OPAQUE_ID_MASK))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Opaque LSA types will be assigned by IANA.
|
|
|
|
* <http://www.iana.org/assignments/ospf-opaque-types>
|
|
|
|
*/
|
|
|
|
#define OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA 1
|
|
|
|
#define OPAQUE_TYPE_SYCAMORE_OPTICAL_TOPOLOGY_DESC 2
|
|
|
|
#define OPAQUE_TYPE_GRACE_LSA 3
|
Update Traffic Engineering Support for OSPFD
NOTE: I am squashing several commits together because they
do not independently compile and we need this ability to
do any type of sane testing on the patches. Since this
series builds together I am doing this. -DBS
This new structure is the basis to get new link parameters for
Traffic Engineering from Zebra/interface layer to OSPFD and ISISD
for the support of Traffic Engineering
* lib/if.[c,h]: link parameters struture and get/set functions
* lib/command.[c,h]: creation of a new link-node
* lib/zclient.[c,h]: modification to the ZBUS message to convey the
link parameters structure
* lib/zebra.h: New ZBUS message
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Add support for IEEE 754 format
* lib/stream.[c,h]: Add stream_get{f,d} and stream_put{f,d}) demux and muxers to
safely convert between big-endian IEEE-754 single and double binary
format, as used in IETF RFCs, and C99. Implementation depends on host
using __STDC_IEC_559__, which should be everything we care about. Should
correctly error out otherwise.
* lib/network.[c,h]: Add ntohf and htonf converter
* lib/memtypes.c: Add new memeory type for Traffic Engineering support
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Add link parameters support to Zebra
* zebra/interface.c:
- Add new link-params CLI commands
- Add new functions to set/get link parameters for interface
* zebra/redistribute.[c,h]: Add new function to propagate link parameters
to routing daemon (essentially OSPFD and ISISD) for Traffic Engineering.
* zebra/redistribute_null.c: Add new function
zebra_interface_parameters_update()
* zebra/zserv.[c,h]: Add new functions to send link parameters
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Add support of new link-params CLI to vtysh
In vtysh_config.c/vtysh_config_parse_line(), it is not possible to continue
to use the ordered version for adding line i.e. config_add_line_uniq() to print
Interface CLI commands as it completely break the new LINK_PARAMS_NODE.
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Update Traffic Engineering support for OSPFD
These patches update original code to RFC3630 (OSPF-TE) and add support of
RFC5392 (Inter-AS v2) & RFC7471 (TE metric extensions) and partial support
of RFC6827 (ASON - GMPLS).
* ospfd/ospf_dump.[c,h]: Add new dump functions for Traffic Engineering
* ospfd/ospf_opaque.[c,h]: Add new TLV code points for RFC5392
* ospfd/ospf_packet.c: Update checking of OSPF_OPTION
* ospfd/ospf_vty.[c,h]: Update ospf_str2area_id
* ospfd/ospf_zebra.c: Add new function ospf_interface_link_params() to get
Link Parameters information from the interface to populate Traffic Engineering
metrics
* ospfd/ospfd.[c,h]: Update OSPF_OPTION flags (T -> MT and new DN)
* ospfd/ospf_te.[c,h]: Major modifications to update the code to new
link parameters structure and new RFCs
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
tmp
2016-04-19 16:21:46 +02:00
|
|
|
#define OPAQUE_TYPE_L1VPN_LSA 5
|
|
|
|
#define OPAQUE_TYPE_ROUTER_INFORMATION_LSA 4
|
|
|
|
#define OPAQUE_TYPE_INTER_AS_LSA 6
|
2018-01-18 19:11:11 +01:00
|
|
|
#define OPAQUE_TYPE_EXTENDED_PREFIX_LSA 7
|
|
|
|
#define OPAQUE_TYPE_EXTENDED_LINK_LSA 8
|
|
|
|
#define OPAQUE_TYPE_MAX 8
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2022-04-01 22:27:55 +02:00
|
|
|
/* Following types are proposed in internet-draft documents. */
|
2002-12-13 21:15:29 +01:00
|
|
|
#define OPAQUE_TYPE_8021_QOSPF 129
|
|
|
|
#define OPAQUE_TYPE_SECONDARY_NEIGHBOR_DISCOVERY 224
|
|
|
|
#define OPAQUE_TYPE_FLOODGATE 225
|
|
|
|
|
|
|
|
/* Ugly hack to make use of an unallocated value for wildcard matching! */
|
|
|
|
#define OPAQUE_TYPE_WILDCARD 0
|
|
|
|
|
|
|
|
#define OPAQUE_TYPE_RANGE_UNASSIGNED(type) \
|
Update Traffic Engineering Support for OSPFD
NOTE: I am squashing several commits together because they
do not independently compile and we need this ability to
do any type of sane testing on the patches. Since this
series builds together I am doing this. -DBS
This new structure is the basis to get new link parameters for
Traffic Engineering from Zebra/interface layer to OSPFD and ISISD
for the support of Traffic Engineering
* lib/if.[c,h]: link parameters struture and get/set functions
* lib/command.[c,h]: creation of a new link-node
* lib/zclient.[c,h]: modification to the ZBUS message to convey the
link parameters structure
* lib/zebra.h: New ZBUS message
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Add support for IEEE 754 format
* lib/stream.[c,h]: Add stream_get{f,d} and stream_put{f,d}) demux and muxers to
safely convert between big-endian IEEE-754 single and double binary
format, as used in IETF RFCs, and C99. Implementation depends on host
using __STDC_IEC_559__, which should be everything we care about. Should
correctly error out otherwise.
* lib/network.[c,h]: Add ntohf and htonf converter
* lib/memtypes.c: Add new memeory type for Traffic Engineering support
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Add link parameters support to Zebra
* zebra/interface.c:
- Add new link-params CLI commands
- Add new functions to set/get link parameters for interface
* zebra/redistribute.[c,h]: Add new function to propagate link parameters
to routing daemon (essentially OSPFD and ISISD) for Traffic Engineering.
* zebra/redistribute_null.c: Add new function
zebra_interface_parameters_update()
* zebra/zserv.[c,h]: Add new functions to send link parameters
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Add support of new link-params CLI to vtysh
In vtysh_config.c/vtysh_config_parse_line(), it is not possible to continue
to use the ordered version for adding line i.e. config_add_line_uniq() to print
Interface CLI commands as it completely break the new LINK_PARAMS_NODE.
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Update Traffic Engineering support for OSPFD
These patches update original code to RFC3630 (OSPF-TE) and add support of
RFC5392 (Inter-AS v2) & RFC7471 (TE metric extensions) and partial support
of RFC6827 (ASON - GMPLS).
* ospfd/ospf_dump.[c,h]: Add new dump functions for Traffic Engineering
* ospfd/ospf_opaque.[c,h]: Add new TLV code points for RFC5392
* ospfd/ospf_packet.c: Update checking of OSPF_OPTION
* ospfd/ospf_vty.[c,h]: Update ospf_str2area_id
* ospfd/ospf_zebra.c: Add new function ospf_interface_link_params() to get
Link Parameters information from the interface to populate Traffic Engineering
metrics
* ospfd/ospfd.[c,h]: Update OSPF_OPTION flags (T -> MT and new DN)
* ospfd/ospf_te.[c,h]: Major modifications to update the code to new
link parameters structure and new RFCs
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
tmp
2016-04-19 16:21:46 +02:00
|
|
|
(OPAQUE_TYPE_MAX <= (type) && (type) <= 127)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
#define OPAQUE_TYPE_RANGE_RESERVED(type) (127 < (type) && (type) <= 255)
|
|
|
|
|
2022-10-19 13:50:41 +02:00
|
|
|
#define OSPF_OPAQUE_LSA_MIN_SIZE 0 /* RFC5250 imposes no minimum */
|
2021-08-11 01:21:19 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#define VALID_OPAQUE_INFO_LEN(lsahdr) \
|
|
|
|
((ntohs((lsahdr)->length) >= sizeof(struct lsa_header)) \
|
ospfd: Correct Coverity defects
When browsing or parsing OSPF LSA TLVs, we need to use the LSA length which is
part of the LSA header. This length, encoded in 16 bits, must be first
converted to host byte order with ntohs() function. However, Coverity Scan
considers that ntohs() function return TAINTED data. Thus, when the length is
used to control for() loop, Coverity Scan marks this part of the code as defect
with "Untrusted Loop Bound" due to the usage of Tainted variable. Similar
problems occur when browsing sub-TLV where length is extracted with ntohs().
To overcome this limitation, a size attribute has been added to the ospf_lsa
structure. The size is set when lsa->data buffer is allocated. In addition,
when an OSPF packet is received, the size of the payload is controlled before
contains is processed. For OSPF LSA, this allow a secure buffer allocation.
Thus, new size attribute contains the exact buffer allocation allowing a
strict control during TLV browsing.
This patch adds extra control to bound for() loop during TLV browsing to
avoid potential problem as suggested by Coverity Scan. Controls are based
on new size attribute of the ospf_lsa structure to avoid any ambiguity.
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-04-06 12:09:25 +02:00
|
|
|
&& ((ntohs((lsahdr)->length) < OSPF_MAX_LSA_SIZE)) \
|
2018-03-27 21:13:34 +02:00
|
|
|
&& ((ntohs((lsahdr)->length) % sizeof(uint32_t)) == 0))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-20 19:57:43 +02:00
|
|
|
/*
|
|
|
|
* Following section defines generic TLV (type, length, value) macros,
|
|
|
|
* used for various LSA opaque usage e.g. Traffic Engineering.
|
|
|
|
*/
|
2017-07-21 16:34:33 +02:00
|
|
|
struct tlv_header {
|
2018-03-27 21:13:34 +02:00
|
|
|
uint16_t type; /* Type of Value */
|
|
|
|
uint16_t length; /* Length of Value portion only, in bytes */
|
2017-07-20 19:57:43 +02:00
|
|
|
};
|
|
|
|
|
2017-07-31 16:39:00 +02:00
|
|
|
#define TLV_HDR_SIZE (sizeof(struct tlv_header))
|
2017-07-20 19:57:43 +02:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
#define TLV_BODY_SIZE(tlvh) (ROUNDUP(ntohs((tlvh)->length), sizeof(uint32_t)))
|
2017-07-20 19:57:43 +02:00
|
|
|
|
2020-11-03 23:07:08 +01:00
|
|
|
#define TLV_SIZE(tlvh) (uint32_t)(TLV_HDR_SIZE + TLV_BODY_SIZE(tlvh))
|
2017-07-20 19:57:43 +02:00
|
|
|
|
|
|
|
#define TLV_HDR_TOP(lsah) \
|
2017-07-31 16:39:00 +02:00
|
|
|
(struct tlv_header *)((char *)(lsah) + OSPF_LSA_HEADER_SIZE)
|
2017-07-20 19:57:43 +02:00
|
|
|
|
|
|
|
#define TLV_HDR_NEXT(tlvh) \
|
2017-07-31 16:39:00 +02:00
|
|
|
(struct tlv_header *)((char *)(tlvh) + TLV_SIZE(tlvh))
|
2017-07-20 19:57:43 +02:00
|
|
|
|
|
|
|
#define TLV_HDR_SUBTLV(tlvh) \
|
2017-07-31 16:39:00 +02:00
|
|
|
(struct tlv_header *)((char *)(tlvh) + TLV_HDR_SIZE)
|
2017-07-20 19:57:43 +02:00
|
|
|
|
2017-07-31 16:39:00 +02:00
|
|
|
#define TLV_DATA(tlvh) (void *)((char *)(tlvh) + TLV_HDR_SIZE)
|
2017-07-20 19:57:43 +02:00
|
|
|
|
2017-07-31 16:39:00 +02:00
|
|
|
#define TLV_TYPE(tlvh) tlvh.header.type
|
|
|
|
#define TLV_LEN(tlvh) tlvh.header.length
|
|
|
|
#define TLV_HDR(tlvh) tlvh.header
|
2017-07-20 19:57:43 +02:00
|
|
|
|
|
|
|
/* Following declaration concerns the Opaque LSA management */
|
|
|
|
enum lsa_opcode { REORIGINATE_THIS_LSA, REFRESH_THIS_LSA, FLUSH_THIS_LSA };
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Prototypes. */
|
|
|
|
|
|
|
|
extern void ospf_opaque_init(void);
|
|
|
|
extern void ospf_opaque_term(void);
|
2018-02-03 19:30:33 +01:00
|
|
|
extern void ospf_opaque_finish(void);
|
2002-12-13 21:15:29 +01:00
|
|
|
extern int ospf_opaque_type9_lsa_init(struct ospf_interface *oi);
|
|
|
|
extern void ospf_opaque_type9_lsa_term(struct ospf_interface *oi);
|
2023-11-27 14:13:03 +01:00
|
|
|
extern void ospf_opaque_type9_lsa_if_cleanup(struct ospf_interface *oi);
|
2002-12-13 21:15:29 +01:00
|
|
|
extern int ospf_opaque_type10_lsa_init(struct ospf_area *area);
|
|
|
|
extern void ospf_opaque_type10_lsa_term(struct ospf_area *area);
|
|
|
|
extern int ospf_opaque_type11_lsa_init(struct ospf *ospf);
|
|
|
|
extern void ospf_opaque_type11_lsa_term(struct ospf *ospf);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
extern int ospf_register_opaque_functab(
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t lsa_type, uint8_t opaque_type,
|
2002-12-13 21:15:29 +01:00
|
|
|
int (*new_if_hook)(struct interface *ifp),
|
|
|
|
int (*del_if_hook)(struct interface *ifp),
|
|
|
|
void (*ism_change_hook)(struct ospf_interface *oi, int old_status),
|
|
|
|
void (*nsm_change_hook)(struct ospf_neighbor *nbr, int old_status),
|
|
|
|
void (*config_write_router)(struct vty *vty),
|
|
|
|
void (*config_write_if)(struct vty *vty, struct interface *ifp),
|
|
|
|
void (*config_write_debug)(struct vty *vty),
|
2021-10-08 02:06:01 +02:00
|
|
|
void (*show_opaque_info)(struct vty *vty, struct json_object *json,
|
|
|
|
struct ospf_lsa *lsa),
|
2002-12-13 21:15:29 +01:00
|
|
|
int (*lsa_originator)(void *arg),
|
2011-03-22 16:23:55 +01:00
|
|
|
struct ospf_lsa *(*lsa_refresher)(struct ospf_lsa *lsa),
|
2002-12-13 21:15:29 +01:00
|
|
|
int (*new_lsa_hook)(struct ospf_lsa *lsa),
|
|
|
|
int (*del_lsa_hook)(struct ospf_lsa *lsa));
|
2018-03-27 21:13:34 +02:00
|
|
|
extern void ospf_delete_opaque_functab(uint8_t lsa_type, uint8_t opaque_type);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
extern int ospf_opaque_new_if(struct interface *ifp);
|
|
|
|
extern int ospf_opaque_del_if(struct interface *ifp);
|
2005-05-06 23:37:42 +02:00
|
|
|
extern void ospf_opaque_ism_change(struct ospf_interface *oi, int old_status);
|
|
|
|
extern void ospf_opaque_nsm_change(struct ospf_neighbor *nbr, int old_status);
|
2017-07-31 16:39:00 +02:00
|
|
|
extern void ospf_opaque_config_write_router(struct vty *vty, struct ospf *ospf);
|
2005-05-06 23:37:42 +02:00
|
|
|
extern void ospf_opaque_config_write_if(struct vty *vty, struct interface *ifp);
|
2002-12-13 21:15:29 +01:00
|
|
|
extern void ospf_opaque_config_write_debug(struct vty *vty);
|
2020-07-24 01:25:04 +02:00
|
|
|
extern void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa,
|
|
|
|
json_object *json);
|
2018-03-27 21:13:34 +02:00
|
|
|
extern void ospf_opaque_lsa_dump(struct stream *s, uint16_t length);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
extern void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi,
|
|
|
|
int *init_delay);
|
2017-07-31 16:39:00 +02:00
|
|
|
extern struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa,
|
2005-05-06 23:37:42 +02:00
|
|
|
int rt_recalc);
|
2011-03-22 16:23:55 +01:00
|
|
|
extern struct ospf_lsa *ospf_opaque_lsa_refresh(struct ospf_lsa *lsa);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
extern void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t lsa_type,
|
|
|
|
uint8_t opaque_type);
|
2002-12-13 21:15:29 +01:00
|
|
|
extern void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa);
|
|
|
|
extern void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
extern void ospf_opaque_self_originated_lsa_received(struct ospf_neighbor *nbr,
|
2005-05-11 20:09:59 +02:00
|
|
|
struct ospf_lsa *lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
extern struct ospf *oi_to_top(struct ospf_interface *oi);
|
|
|
|
|
2022-01-08 22:57:10 +01:00
|
|
|
extern int ospf_opaque_is_owned(struct ospf_lsa *lsa);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#endif /* _ZEBRA_OSPF_OPAQUE_H */
|