diff options
| author | vivek <vivek@cumulusnetworks.com> | 2016-02-25 19:30:53 +0000 |
|---|---|---|
| committer | vivek <vivek@cumulusnetworks.com> | 2016-02-25 19:30:53 +0000 |
| commit | c8e264b60e405e60b666cca62d5c96c20a9cf3bd (patch) | |
| tree | 85f3ad0f6bf667d1ddb04a5330fe51bb1bc3d1e4 /lib | |
| parent | b47b0a8480cbbfa30de4794f149f39ca8ad43921 (diff) | |
Quagga: Implement VRF change semantics for an interface
Implement VRF change semantics for an interface to be invoked
when an interface is moved from one VRF (e.g., the Default) to
another. This includes the message definition as well as updating,
deleting or adding the interface from clients, depending on their
interest in the VRFs (old and new). Also handle replay of the
addresses on the interface upon VRF change, if required.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Ticket: CM-9527
Reviewed By: CCR-4174
Testing Done: Manual tests of various scenarios
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/log.c | 3 | ||||
| -rw-r--r-- | lib/zclient.c | 31 | ||||
| -rw-r--r-- | lib/zclient.h | 3 | ||||
| -rw-r--r-- | lib/zebra.h | 3 |
4 files changed, 38 insertions, 2 deletions
@@ -874,7 +874,8 @@ static const struct zebra_desc_table command_types[] = { DESC_ENTRY (ZEBRA_REDISTRIBUTE_IPV4_ADD), DESC_ENTRY (ZEBRA_REDISTRIBUTE_IPV4_DEL), DESC_ENTRY (ZEBRA_REDISTRIBUTE_IPV6_ADD), - DESC_ENTRY (ZEBRA_REDISTRIBUTE_IPV6_DEL) + DESC_ENTRY (ZEBRA_REDISTRIBUTE_IPV6_DEL), + DESC_ENTRY (ZEBRA_INTERFACE_VRF_UPDATE) }; #undef DESC_ENTRY diff --git a/lib/zclient.c b/lib/zclient.c index 82f0c26e59..655eda8176 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1211,6 +1211,33 @@ zebra_interface_nbr_address_read (int type, struct stream *s, vrf_id_t vrf_id) return ifc; } +struct interface * +zebra_interface_vrf_update_read (struct stream *s, vrf_id_t vrf_id, + vrf_id_t *new_vrf_id) +{ + unsigned int ifindex; + struct interface *ifp; + vrf_id_t new_id = VRF_DEFAULT; + + /* Get interface index. */ + ifindex = stream_getl (s); + + /* Lookup interface. */ + ifp = if_lookup_by_index_vrf (ifindex, vrf_id); + if (ifp == NULL) + { + zlog_warn ("INTERFACE_VRF_UPDATE: Cannot find IF %u in VRF %d", + ifindex, vrf_id); + return NULL; + } + + /* Fetch new VRF Id. */ + new_id = stream_getw (s); + + *new_vrf_id = new_id; + return ifp; +} + /* Zebra client message read function. */ static int zclient_read (struct thread *thread) @@ -1357,6 +1384,10 @@ zclient_read (struct thread *thread) if (zclient->interface_down) (*zclient->interface_down) (command, zclient, length, vrf_id); break; + case ZEBRA_INTERFACE_VRF_UPDATE: + if (zclient->interface_vrf_update) + (*zclient->interface_vrf_update) (command, zclient, length, vrf_id); + break; case ZEBRA_IPV4_ROUTE_ADD: if (zclient->ipv4_route_add) (*zclient->ipv4_route_add) (command, zclient, length, vrf_id); diff --git a/lib/zclient.h b/lib/zclient.h index e58870828b..49f73b3e9b 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -98,6 +98,7 @@ struct zclient int (*interface_bfd_dest_update) (int, struct zclient *, uint16_t, vrf_id_t); int (*interface_nbr_address_add) (int, struct zclient *, uint16_t, vrf_id_t); int (*interface_nbr_address_delete) (int, struct zclient *, uint16_t, vrf_id_t); + int (*interface_vrf_update) (int, struct zclient *, uint16_t, vrf_id_t); int (*ipv4_route_add) (int, struct zclient *, uint16_t, vrf_id_t); int (*ipv4_route_delete) (int, struct zclient *, uint16_t, vrf_id_t); int (*ipv6_route_add) (int, struct zclient *, uint16_t, vrf_id_t); @@ -200,6 +201,8 @@ extern struct interface *zebra_interface_add_read (struct stream *, vrf_id_t); extern struct interface *zebra_interface_state_read (struct stream *s, vrf_id_t); extern struct connected *zebra_interface_address_read (int, struct stream *, vrf_id_t); extern struct nbr_connected *zebra_interface_nbr_address_read (int, struct stream *, vrf_id_t); +extern struct interface * zebra_interface_vrf_update_read (struct stream *s, vrf_id_t vrf_id, + vrf_id_t *new_vrf_id); extern void zebra_interface_if_set_value (struct stream *, struct interface *); extern void zebra_router_id_update_read (struct stream *s, struct prefix *rid); extern int zapi_ipv4_route (u_char, struct zclient *, struct prefix_ipv4 *, diff --git a/lib/zebra.h b/lib/zebra.h index 3d38a4c5cb..2945f15194 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -445,7 +445,8 @@ struct in_pktinfo #define ZEBRA_VRF_UNREGISTER 42 #define ZEBRA_VRF_ADD 43 #define ZEBRA_VRF_DELETE 44 -#define ZEBRA_MESSAGE_MAX 45 +#define ZEBRA_INTERFACE_VRF_UPDATE 45 +#define ZEBRA_MESSAGE_MAX 46 /* Marker value used in new Zserv, in the byte location corresponding * the command value in the old zserv header. To allow old and new |
