Commit Graph

634 Commits

Author SHA1 Message Date
Donald Sharp
5523c15692 zebra: Send correct default vrf tableid for MROUTE stats
So the linux kernel uses the RT_TABLE_MAIN for the table
id used for ip routing.  The multicast routing tables use
RT_TABLE_DEFAULT.  We changed the internal code of zebra_vrf
a few months back to use RT_TABLE_MAIN as the tableid to
use.  This caused the pim sg stats to stop working because
of the kernel bug where it uses a different table
for ip routing and ip multicast.

Put a bit of a special case in to do the right thing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-17 09:22:31 -04:00
Donald Sharp
c25e2f1ad1 zebra: Newer kernels send data about mroute changes
Newer linux kernels apparently send data down the netlink
bus for the creation of mroutes.  Add a bit of code
to notice this and to handle it appropriately( ie do
nothing at this point in time ) as that the correct
place to do this is in the pim socket in pimd.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-14 17:54:11 -04:00
Donald Sharp
87b5d1b098 zebra: Print out netlink message type instead of number
When we are displaying data about a netlink message
in debugs or errors, print out the message type
as a string instead of a number.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-14 17:48:51 -04:00
Quentin Young
e914ccbe9c zebra: ZEBRA_[ERR|WARN] -> EC_ZEBRA
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:23:29 +00:00
Donald Sharp
6efca3442f
Merge pull request #3007 from pacovn/static_analysis__shadow_variables2
lib vtysh zebra: variable shadowing fixes
2018-09-13 08:38:32 -04:00
David Lamparter
e991eff5b5 Merge remote-tracking branch 'frr/master' into warnings
Conflicts:
	zebra/if_ioctl_solaris.c
	zebra/rtread_getmsg.c

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-12 21:58:39 +02:00
F. Aragon
c683bd446c
lib vtysh zebra: variable shadowing fixes
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-12 12:27:38 +02:00
Quentin Young
364fed6b07 zebra: fix includes
Add and remove error related includes as necessary.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06 20:56:41 +00:00
Quentin Young
9df414feeb zebra: flog_warn conversion
Convert Zebra to user error subsystem.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06 20:56:38 +00:00
Christian Franke
da82f6b42a zebra: add RTPROT_FABRICD route type 197
Add an iproute2 route type for fabricd

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-09-05 11:38:12 +02:00
Donald Sharp
5b4256ca42 zebra: Fix crash in mroute debug
There exists a possibility that the ifindex we are passed
does not exist and as such we should check for it not
resolving as part of the debug.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-28 10:35:35 -04:00
Stephen Worley
87da6a6019 zebra: Add support for static encap mpls labels
We were ignoring mpls labels encapped with static routes.
Added support for single and multipath labels.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-25 13:19:07 -04:00
Martin Winter
09890489cc
Merge pull request #2122 from donaldsharp/zebra_nhs
Create Staticd
2018-08-08 08:07:24 -07:00
Renato Westphal
c3d098ab30
Merge pull request #2726 from sworleys/Netlink-Filter-AFI
zebra: Ignore AF_ETHERNET and AF_MPLS in route change as well
2018-08-06 20:26:46 -03:00
Donald Sharp
51c4ed0a0e staticd, zebra: Fix up code warnings
CI found a couple of warnings that needed to be cleaned up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29 13:06:49 -04:00
Donald Sharp
40ecd8e46d lib, zebra: Allow protocols to use Distance as part of RR semantics
Allow protocols to specify to zebra that they would like zebra
to use the distance passed down as part of determine sameness for
Route Replace semantics.

This will be used by the static daemon to allow it to have
backup static routes with greater distances.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29 12:43:23 -04:00
Stephen Worley
2e2b0fb3c2
Merge branch 'master' into Netlink-Prefix-Len-Check 2018-07-26 15:34:56 -04:00
Stephen Worley
e17d9b2dfe zebra: Make prefix length check return error
Prefix length validation checks should be returning an error
rather than 0. Switch to that and make them error messages.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-26 15:10:53 -04:00
Stephen Worley
8122787440 zebra: Format log for address family check
Switched the address family check to use unsigned format.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-25 14:08:24 -04:00
Stephen Worley
de1cd6b913 zebra: Ignore AF_ETHERNET and AF_MPLS in route_change as well
Remove AF_ETHERNET and AF_MPLS as valid address families for route
changes.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-25 14:02:00 -04:00
Russ White
4dbd617abd
Merge pull request #2704 from sworleys/Netlink-Nexthop-Hang
zebra: Add check for nexthop loop to prevent hanging
2018-07-24 19:42:11 -04:00
Russ White
bbc7adf1b4
Merge pull request #2665 from chiragshah6/evpn_dev
bgpd: support evpn nd ext community
2018-07-24 11:55:08 -04:00
Stephen Worley
758297039c Change log statements to use unsigned format
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-24 11:14:07 -04:00
Christian Franke
1f610a1fb3 zebra: do not ignore ipv6 srcdest routes
Commit a2ca67d1d2 consolidated IPv4 and IPv6 handling. It also applied
our ignorance for IPv4 srcdest routes onto IPv6.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-07-24 14:09:17 +02:00
Stephen Worley
3c04071d99 zebra: Add check for nexthop loop to prevent hanging
Bad nexthop messages from netlink were causing zebra
to hang here. Added a check to verify the length
of the nexthop so it doesn't keep trying to read.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-23 18:51:26 -04:00
Stephen Worley
adac720d77 Remove not needed filters and fix typos
Some more address family filters we can safely ignore
as well as typos in logger. Added AF_MPLS as filterable.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-23 15:08:37 -04:00
Stephen Worley
930571d24f zebra: Add check for prefix length from kernel messages
Zebra needed a check that varifies the prefix length
of an address is a valid length when receiving route
changes and interface address changes.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-23 14:21:59 -04:00
Stephen Worley
8a1b681cba zebra: Add address family filters
The zebra netlink socket was attempting to read netlink
messages with invalid address families in a couple areas.
Added filters and warn messages.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-23 12:11:02 -04:00
Chirag Shah
68e331515e bgpd: support evpn nd ext community
EVPN ND ext community support NA flag R-bit, to have proxy ND.

Set R-bit in EVPN NA if a given router is default gateway or there is a
local
router attached, which can be determine based on local neighbor entry.

Implement BGP ext community attribute to generate and parse  R-bit and
pass along zebra to program neigh entry in kernel.

Upon receiving MAC/IP update with community type 0x06 and sub_type 0x08,
pass the R-bit to zebra to program neigh entry.

Set NTF_ROUTER in neigh entry and inform kernel to do proxy NA for EVPN.

Ref:
https://tools.ietf.org/html/draft-ietf-bess-evpn-na-flags-01

Ticket:CM-21712, CM-21711
Reviewed By:
Testing Done:
Configure Local vni enabled L3 Gateway, which would act as router,
checked
show evpn arp-cache vni x ip <ip of svi> on originated and remote VTEPs.
"Router" flag is set.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-07-17 13:06:41 -07:00
Donald Sharp
51034b787f
Merge pull request #2595 from pguibert6WIND/fix_netlink_rx_route_vrfnetns
zebra: upon RTM_NEWROUTE/DELROUTE, find appropriate interface
2018-07-12 22:22:34 -04:00
Mark Stapp
86391e5659 zebra, libs: use const prefix ptrs in apis
Add 'const' to prefix args to several zebra route update,
redistribution, and route owner notification apis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-07-11 09:22:49 -04:00
Philippe Guibert
fac4d51eea zebra: upon RTM_NEWROUTE/DELROUTE, find appropriate interface
The interface lookup algorithm is different according to if we are on
netns vrf or not. If we are on the former case, then we only have to
parse the interfaces of the netns, while if we are on the other case, we
have to parse all the interfaces of all the vrfs ( since index is not
overlapping in the latter case).

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-10 17:32:23 +02:00
Donald Sharp
9bdf861803 zebra: Add error messages in places where we have a decode problem
When we receive a netlink message from the kernel we have
handler functions for when we send a netlink command, if these
return a failure ( < 0 ) then we output that we had a parse
issue.  But if all we get is:

2018-06-21T23:47:45.298156+00:00 qct-ix1-08 zebra[1484]: netlink-cmd (NS 0) filter function error

Then it is not very useful to figure out *where* the error happened.

Add more error code when in a decode path to hopefully allow us
to figure out where this message is coming from.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-25 10:02:48 -04:00
Donald Sharp
1e88567226 zebra: Add a result from dataplane request
Add a bit of code to allow return of data plane
request messages.

Add the ability to pass the result back to callers
of kernel_route_rib.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-30 08:03:13 -04:00
Donald Sharp
215181cbf1 zebra: Rename SOUTHBOUND_XXX to DP_XXX
The SOUTHBOUND_XXX enum was named a bit poorly.
Let's use a bit better name for what we are trying to do.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-30 08:00:55 -04:00
Russ White
e73f79ac4c
Merge pull request #2283 from donaldsharp/ignore_some_more
zebra: netlink cleanups
2018-05-27 11:02:15 -04:00
Donald Sharp
6ab5222f78 zebra: Add a breadcrumb for when we ignore a route
When we receive a route that we think we own and we
are not in startup conditions, then add a small debug
to help debug the issue when this happens, instead
of silently just ignoring the route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-26 08:46:13 +02:00
Donald Sharp
d4d71f1133 tools, zebra: Use different protocol value for our statics
The re-use of RTPROT_STATIC has caused too many collisions
where other legitimate route sources are causing us to
believe we are the originator of the route.  Modify
the code so that if another protocol inserts RTPROT_STATIC
we will assume it's a Kernel Route.

Fixes: #2293
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-26 08:46:13 +02:00
Donald Sharp
2414abd3b0 zebra: Remove unnecessary function parameter
The snl variable is no longer needed to be passed around, so
remove it from the calling path.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-24 09:14:43 -04:00
Donald Sharp
6b093863ec zebra: Allow runtime determination of v6 RR semantics
The linux kernel is getting the same Route Replace semantics
for v6 that v4 uses.  Allow the end-user to know if their
kernel has this ability and if so to specify it so zebra
can take advantage of this.

Why not do auto-detection?  Because you would have to write
code in zebra to add a route then add the same route again
with different nexthops to see if which semantics it is using.
It sure is easier to just add a cli that allows the user to
do it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-18 15:42:17 -04:00
Donald Sharp
5605ecfc1f zebra: memset buf to prevent uninited writes into kernel
Setup the buf used for extra data passed into kernel such
that we are cleaning it out before writing data to it,
so we can avoid writing uninited data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-17 18:46:14 -04:00
vivek
6c0a605355 bgpd: Fix VRF route leaking for multipath routes
Ensure that the next hop of the leaked VRF is not overwritten when the
route is being imported into the target VRF from the VPN table. Also, in
the case of multipath routes, ensure that the nexthop's ifindex is not
inadvertently reset.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
vivek
22e63104d2 bgpd, zebra: Handle EVPN router MAC per next hop
Ensure that when EVPN routes are installed into zebra, the router MAC
is passed per next hop and appropriately handled. This is required for
proper multipath operation.

Ticket: CM-18999
Reviewed By:
Testing Done: Verified failed scenario, other manual tests
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
Donald Sharp
0761368af0 zebra: Add PBR and SHARP handling
We are missing some handling of PBR and SHARP protocols
for netlink operations w/ the linux kernel.

Additionally add a bread crumb for new developers( or existing )
to know to fixup the rt_netlink.c when we start handling new
route types to hand to the kernel.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-27 14:59:52 -04:00
Quentin Young
bf094f6975 zebra: clean up zapi organization
zserv.c has become something of a dumping ground for everything vaguely
related to ZAPI and really needs some love. This change splits out the
code fo building and consuming ZAPI messages into a separate source
file, leaving the actual session and client lifecycle code in zserv.c.

Unfortunately since the #include situation in Zebra has not been paid
much attention I was forced to fix the headers in a lot of other source
files. This is a net improvement overall though.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 22:50:24 -04:00
Russ White
ea1c08342f
Merge pull request #2072 from donaldsharp/blackhole_this
zebra: Allow blackhole route deletion for prefixes
2018-04-20 07:58:03 -04:00
Donald Sharp
c766824c62 zebra: Allow blackhole route deletion for prefixes
With the recent change to just pass the prefix in
for the RTM_DELROUTE, for blackhole routes we
had stopped modifying the req.rtm_type to
be the appropriate type for blackhole routes.

Since we are just deleting on the route, and
zebra is never going to really install the same
route multiple times then we do not need
to specify the req.r.rtm_type for the deletion
command.

Ticket: CM-20616
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-16 18:42:40 -04:00
Mitesh Kanjariya
e9d2cbdebf zebra: add EVPN learned neighbors as NUD_NOARP
EVPN owns the remote neigh entries which are programed in the kernel.
This entries should not age out and the only way to delete should be
from EVPN. We should program these entries with NUD_NOARP instead of
NUD_REACHABLE to avoid aging of this macs.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-04-12 09:07:43 -04:00
Mitesh Kanjariya
ee69da278d zebra: act on kernel notifications for remote neighbors as well
There can be a race condition between kernel and frr as follows.
Frr sends remote neigh notification.
At the (almost) same time kernel might send a notification saying
neigh is local.
After processing this notifications, the state in frr is local while
state in kernel is remote. This causes kernel and frr to be out of sync.
This problem will be avoided if FRR acts on the kernel notifications for
remote neighbors. When FRR sees a remote neighbor notification for a
neighbor which it thinks is local, FRR will change the neigh state to remote.

Ticket: CM-19923/CM-18830
Review: CCR-7222
Testing: Manual

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-04-12 09:07:43 -04:00
Renato Westphal
0742ce0a86
Merge pull request #2043 from donaldsharp/v6_shenanigans
V6 shenanigans
2018-04-10 17:38:00 -03:00
Donald Sharp
c1d63a9346 zebra: Only send down pertinent information on RTM_DELROUTE
Background:

v6 does not have route replace semantics.  If you want to add a nexthop
to an existing route, you just send RTM_NEWROUTE and the new nexthop.
If you want to delete a nexthop you should just send RTM_DELROUTE
with the removed nexthop.

This leads to situations where if zebra is processing a route
and has lost track of intermediate nexthops( yes this sucks )
then v6 routes will get out of sync when we try to implement
route replace semantics.

So notice when we are doing a route delete and the route is
not being updated, just send the prefix and tell it too delete.

Ticket: CM-20391
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-09 14:16:00 -04:00
Donald Sharp
45df4e9667 zebra: Cleanup debugs and add a bit more info
This commit does 2 things:

1) When receiving a route from the kernel, display the incoming
table as part of the debug, to facilatate knowing what we are
talking about as part of the debug.

2) When displaying nexthop information for routes we were sending
to the kernel, no need to display the route information every time
Display the route then the individual nexthops for what we are doing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-09 14:09:35 -04:00
Donald Sharp
20089ae2e4 zebra: Notice when our neighbor entry is removed and fight back
Notice when someone deletes a neighbor entry we've put in for
rfc-5549 gets deleted by some evil evil person.  When this happens
notice and push it back in, immediately.

Ticket: CM-18612
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-09 08:04:39 -04:00
Donald Sharp
7556c3fda8 zebra: Add table and nexthop vrf information to netlink debug
Add some additional debug information to the netlink debug
messages so we can see the table we are installing to as
well as the nexthop's vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-29 08:58:45 -04:00
Quentin Young
d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27 15:13:34 -04:00
Donald Sharp
7ee30f288e lib: Isolate nexthop_group functions to nexthop_group.c
Also modify `struct route_entry` to use nexthop_groups.
Move ALL_NEXTHOPS loop to nexthop_group.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Lou Berger
996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00
Philippe Guibert
009f8ad5f3 zebra: retrieve zns context from zvrf when netlink discovery
So as to get the correct NETNS where some discovery must be done and
populated, the zns pointer is directly retrieved from zvrf, instead of
checking that the VRF is a backend NETNS or not.
In the case where the interfaces are discovered before the VRF is enabled
( VRF-lite populate), then the default NS is retrieved.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert
5895d33f40 zebra: ipv6 operations stick to namespace
All ipv6 operations stick to namespace.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert
9a76375f39 zebra: route configuration fix for vrf when applied to namespaces
For each route to be added or deleted, instead of applying directly to
default namespaces, when a vrf is mapped to a namespace, then the
correct zns must be found out.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert
78dd30b263 zebra: add a runtime flag to enable vrf with netns
The netns backend is chosen by VRF if a runtime flag named vrfwnetns is
selected when running zebra.
In the case the NETNS backend is chosen, in some case the VRFID value is
being assigned the value of the NSID. Within the perimeter of that work,
this is why the vrf_lookup_by_table function is extended with a new
parameter.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:10:41 +01:00
Renato Westphal
fa71296396 zebra: implement recursive MPLS labels
When a BGP-labeled route is resolved into an LDP-labeled IGP route,
zebra would install it with no labels in the kernel. This patch implements
recursive MPLS labels, i.e. make zebra install all labels from the route's
nexthop chain (the labels from the top-level nexthop being installed in
the top of the MPLS label stack). Multiple recursion levels are supported.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-02-19 13:22:57 -05:00
Donald Sharp
70e98a7fe7 *: Make code use a consisten definition of labels
Turns out we had 3 different ways to define labels
all of them overlapping with the same meanings.
Consolidate to 1.  This one choosen is consistent
naming wise with what the *bsd and linux kernels
use.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-08 20:31:37 -05:00
Donald Sharp
4a7371e9e2 *: Track vrfs per nexthop not per route entry
Track the vfrs on a per nexthop basis instead
of on a per route entry basis.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-08 19:35:53 -05:00
Donald Sharp
7d974ba3b7 zebra: Modify southbound interface to pass struct route_node
The route_node that we are working on is going to be interesting
to the kernel_route_rib_pass_fail.  So I am setting up the
code to allow me to pass it.  This will be done in a subsuquent
commit.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-24 08:22:57 -05:00
Philippe Guibert
d6fed38109
Merge pull request #1618 from donaldsharp/zebra_startup_ordering
zebra route-leaking for static routes
2018-01-23 08:25:01 +01:00
Donald Sharp
8ecdb26ec0 lib, zebra: Rename and place appropriately the label stack
Fix and rename the label stack to be better named.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-22 11:55:22 -05:00
Donald Sharp
5e21052204 zebra: Encode the ifindex over netlink
In order for routes to be leaked the ifindex must be sent
down into the kernel over the netlink protocol.  So
send it( we always figure it out ) when we add the
route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:26:42 -05:00
Donald Sharp
8795f90448 zebra: Add nh_vrf_id to rib_add
Add to the rib_add function the ability to pass in the nexthops
vrf.

Additionally when we decode the netlink message from the linux
kernel, properly figure out the nexthops vrf_id.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:20:36 -05:00
Donald Sharp
8f43b4d886 zebra: Add nh_vrf_id to 'struct route_entry`
With VRF route-leaking we need to know what vrf
the nexthops are in compared to this vrf.  This
code adds the nh_vrf_id to the route entry and
sets it up correctly for the non-route-leaking
case.

The assumption here is that future commits
will make the nh_vrf_id *different* than
the vrf_id.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:20:30 -05:00
Mitesh Kanjariya
9bb77a5b3d
Merge branch 'master' into evpn-symmetric-routing 2018-01-11 09:00:23 -08:00
mitesh
6134fd82a0 zebra: proper refcounting for rmac/nh entries
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.comy>
2017-12-14 10:57:06 -08:00
Kaloyan Kovachev
4e40b6d615 zebra: Add ability to support tags -> realms in linux
Linux has the ability to support a concept of 'realms'.
This concept allows you to mark routes with a realm id
value of 1-255.  If you have marked the realm
of a route then you can use the tc program to
apply policy to the routes.

This commit adds the ability of FRR to interpret
a tag from (1-255) as a realm when installing into
the kernel.  Please note that at this point in time
there is no way to set policy from within FRR.  This
must be done outside of it.

The normal methodology for setting tags is valid here
via a route-map.

Finally this is only applied if the --enable-realms configure
option is applied.

Signed-off-by: Kaloyan Kovachev <kkovachev@varna.net>
2017-12-14 09:44:44 -05:00
Donald Sharp
4a83e7a04a zebra: Fix lsp add/del from kernel using SETFLAG
Setup a interface such that the add/del of lsp's from
the kernel can have a callback for success/failure.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-29 13:01:00 -05:00
Donald Sharp
0c555cc6a5 zebra: Implement call back for route install/delete success/fail
When a route is installed or deleted into the kernel allow a
callback mechanism to handle the success/failure of
the kernel call.

This separation is to allow us to do these things:

1) In the future create a true pthread to handle route
install/deletes.  This way we can schedule these
events in a smarter fashion

2) Allow us to use a common southbound api for route
install and deletion.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-29 12:56:34 -05:00
Donald Sharp
8a71d93d85 sharpd: Add Super Happy Advanced Routing Protocol
Add a daemon that will allow us to test the zapi
as well as test route install/removal times from
the kernel.

The current commands are:

install route <starting ip address> nexthop <nexthop> (1-1000000)

This command starts installing at <starting ip address>/32
(1-100000) routes that it auto-increments by 1
Installation start time is noted in the log and finish
time is noted as well.

remove routes <starting ip address> (1-1000000)

This command removes routes at <starting ip address>/32
and removes (1-100000) routes created by the install route
command.

This code can be considered experimental and *is not*
something that should be run in a production environment.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 09:16:30 -05:00
Donald Sharp
e7fcb84341 zebra: V6 does not have route replace semantics
The v6 linux kernel netlink code doees not have
route replace semantics.  So if we are in that
situation, do a delete/add to get the correct
results.

Fixes: #1461
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-17 11:13:01 -05:00
Donald Sharp
3d468f6604 zebra: Move clear_nhlfe_installed to calling functions
The function clear_nhlfe_installed is to be called
when we get a install failure of some sort for
a lsp change.  Since an install failure can happen
in both linux and openBSD moving the function call
northbound is a good idea.

I've also added it to the kernel_del_lsp for completeness
on failure as well, even though neither linux or openBSD
currently can fail a uninstall.

This still leaves the hole where if we have multiple
nhlfes and have an install failure we are not quite
doing the right thing by just blanketly calling
clear_nhlfe_installed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-27 10:41:07 -04:00
Donald Sharp
f7d9ebf4da Merge pull request #1356 from opensourcerouting/linux-headers
build: include our own copies of some linux kernel headers
2017-10-27 10:12:43 -04:00
Don Slice
8dc8a4b693 zebra: only pass mpls proto type if doing install
Problem reported with not deleting LSPs from the zebra kernal mpls table
when a delete occurred in bgp.  Found that we were exiting the delete
process incorrectly due to not being able to derive the route_type from
the best_nhlre on the lsp while deleting. Since this info was only
needed for route installation, removed this early exit in the case of
deleting the lsp.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Ticket: CM-18309
Reviewed By: CCR-6781
Testing Done:  Manual testing looks good.  mpls tests successful
2017-10-25 08:19:22 -04:00
Renato Westphal
ba7773964c build: include our own copies of some linux kernel headers
This is the definitive solution to avoid build issues on old Linux
systems, where the system kernel headers might not contain some constants
or macros used by FRR (e.g. MPLS_IPTUNNEL_DST, introduced on 2015).

This is the same strategy adopted by other projects, like iproute2,
libnl, lldpd, strongswan, etc. These header files don't need to be in
sync with upstream, they only need to be updated when necessary (e.g. if
we want to use a new feature introduced by a recent kernel).

Fixes #962 using the solution suggested by David Lamparter.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24 09:20:12 -02:00
Donald Sharp
5d920111b9 Merge pull request #1210 from opensourcerouting/misc-mpls-bgp-lu-fixes
Misc BGP-LU fixes
2017-10-10 12:19:37 -04:00
Renato Westphal
e56ab0e971 Merge pull request #1301 from donaldsharp/zebra_vxlan
Zebra vxlan
2017-10-10 09:00:44 -03:00
Renato Westphal
9a62e84b5b zebra: fix logging of MPLS labels
* use %u instead of %d, we don't want to print negative labels;
* increase the size of label_buf to accommodate the worst case scenarios;
* use strlcat() instead of strcat() as a security best practice.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-09 20:15:14 -03:00
Renato Westphal
09d0f308ce Merge pull request #1237 from donaldsharp/distance_special
zebra: Modify metric read to be admin distance and metric
2017-10-09 20:11:39 -03:00
Vincent JARDIN
792fa92ec1 zebra: fix clang warning
Set to 0 to avoid "Branch condition evaluates to a garbage value".

Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-08 23:47:43 +02:00
vivek
2853fed67a zebra: Handle L3 multi-tenancy correctly for EVPN
Fix following flaws that resulted in EVPN with L3 multi-tenancy (i.e.,
EVPN dealing with VxLAN routing in the presence of tenant VRFs) not
working properly:

1. EVPN enable ("advertise-all-vni") is a global command, ensure it is
accordingly processed. The config is maintained against the default VRF.
2. There was an incorrect attempt to derive the L3 VRF for L2 interfaces
- the VRF only applies for L3 interfaces, though the code may initialize
to the default value in other cases.
3. Functions to map (port, VLAN) to SVI or vice versa were incorrect -
particularly, zvni_map_svi() since it was looking in the L3 VRF for
"matching" L2 interface which it would never find. Fix.

In addition, since the 'zebra_vrf *' parameter is not relevant in most
places, it has been removed.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Mitesh Kanjariya <mitesh@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-17840
Reviewed By: CCR-6685
Testing Done: evpn-smoke, various manual tests
2017-10-06 09:59:43 -04:00
Renato Westphal
310f64be93 Merge pull request #1240 from donaldsharp/allow_self_delete
zebra: Do not allow delete of route from kernel in non-startup case
2017-09-27 09:11:11 -03:00
Donald Sharp
5dfeba1904 zebra: Do not allow delete of route from kernel in non-startup case
This is a continuation of 915902cb82.  Basically the netlink
read of messages up from the kernel is now noticing the proper
owner of the route.  As such when rib_delete was being called
as part of the upcall from the kernel we were not noticing that
we were the originator and not diss-allowing the rib_delete
from happening.  This restores this behavior that we were getting
pre-915902cb82cfd

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-25 12:28:39 -04:00
Donald Sharp
25715c7e50 zebra: Modify metric read to be admin distance and metric
For ZEBRA_ROUTE_KERNEL types:

The metric/priority of the route received from the kernel
is a 32 bit number.  We are going to interpret the high
order byte as the Admin Distance and the low order 3 bytes
as the metric.

This will allow us to do two things:
1) Allow the creation of kernel routes that can be
   overridden by zebra.
2) Allow the old behavior for 'most' kernel route types
   if a user enters 'ip route ...' v4 routes get a metric
   of 0 and v6 routes get a metric of 1024.  Both of these
   values will end up with a admin distance of 0, which
   will cause them to win for the purposes of zebra.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-25 08:37:04 -04:00
Renato Westphal
8b1450b94d zebra: fix multihop/multipath confusion
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Renato Westphal
805444ce72 zebra: install MPLS LSPs with appropriate protocol type
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Renato Westphal
7990990e54 zebra: use the afi parameter in rib_add_multipath()
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Jafar Al-Gharaibeh
b1cebe20cd Merge pull request #1157 from donaldsharp/recursive_blackhole
Recursive blackhole resolution
2017-09-21 11:16:35 -05:00
Renato Westphal
a2addae8fe *: use clang's 'ForEachMacros' format style option
This fixes the broken indentation of several foreach loops throughout
the code.

From clang's documentation[1]:
  ForEachMacros: A vector of macros that should be interpreted as foreach
  loops instead of as function calls.

[1] http://clang.llvm.org/docs/ClangFormatStyleOptions.html

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-15 14:53:46 -03:00
David Lamparter
25b9cb0cc8 zebra: deduplicate nexthops
There exists situations where it is possible to have duplicate
nexthops passed from a higher level protocol into zebra.

This code notices this duplication of nexthops and marks
the duplicates as DUPLICATE so we don't attempt to install
it into the kernel.

This is important on *BSD as I understand it because passing
duplicate nexthops will cause the route to be rejected.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-12 10:05:07 -04:00
Donald Sharp
1f1d24a8f1 zebra: Allow recursively resolved blackhole routes to be installed
So the current code for a blackhole route assumed that you
would never want a recursively resolved blackhole to work.
Suppose you have this setup:

1) ip route 192.0.2.1/32 Null0
2) BGP installed with a route-map that rewrites the
   nexthop to 192.0.2.1.

Zebra will end up with a recursive nexthop that resolves
to the blackhole.

The original rib install function assumed that we would never
want the ability to recursively resolve a blackhole route.
Instead just handle the blackhole as part of the nexthop_num = 1
case.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-12 08:33:37 -04:00
Donald Sharp
915902cb82 zebra: Allow zebra to delete self originated routes
With the change to make zebra pass routes to the kernel
with the 'correct' proto name, it caused zebra to
not properly recognize them on startup again
the next time such that the route would not
be deleted.

Modify rt_netlink.c to notice that we have a
self originated route and to properly mark
the type of route it was.

Modify rib_table_sweep to mark the nexthops
as active so that when we go to delete the
self originated routes it would properly
delete from the kernel.

Fixes: #1061
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-05 18:56:36 -04:00
Renato Westphal
8ba5bd58aa zebra: allow blackhole routes from the kernel to be deleted
Fixes the following bug:
% ip -6 route add unreachable 4000::/64
% ip -6 route del unreachable 4000::/64
% vtysh -c "show ipv6 route"
[snip]
K>* 4000::/64 [0/1024] unreachable (ICMP unreachable)

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-31 22:14:48 -03:00
Renato Westphal
1dca2eaa5b zebra: fix compiler error introduced by previous commit
Lesson learned: always wait for the CI tests to finish before merging :)

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-31 20:58:16 -03:00
Donald Sharp
af760ec192 zebra: Allow bh_type to override nexthop selection
If we've set the bh_type to something besides BLACKHOLE_UNSPEC
due to the received route type being RTN_BLACKHOLE,
RTN_UNREACHABLE or RTN_PROHIBIT then just trust that
the nexthop is just what it is and set accordingly.

Fixes: #1082
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-31 19:36:06 -04:00
Renato Westphal
b3c18264e4 Merge pull request #1079 from qlyoung/fix-style-a
*: fix style
2017-08-31 13:22:55 -03:00
Jafar Al-Gharaibeh
959768e8d0 Merge pull request #1044 from donaldsharp/combination
Coverity Cleanup of Stuff
2017-08-31 10:25:55 -05:00
Quentin Young
60466a63f2
*: fix style
Fixes style nits introduced by recent pull requests.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-30 11:27:11 -04:00
David Lamparter
14f6aefe43 Merge pull request #998 from mkanjari/dev-master
Dev master
2017-08-29 20:03:48 +02:00
David Lamparter
e655a03c18 zebra: netlink: get blackhole routes from kernel
support processing of RTN_BLACKHOLE et al. from kernel and dump them
into appropriate blackhole rib entries.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28 05:07:54 +02:00
David Lamparter
a830942228 zebra: cleanup blackhole support
blackhole support was horribly broken. cleanup by removing blackhole
stuff from ZEBRA_FLAG_*

introduces support for "prohibit" routes (Linux/netlink only)
also clean up blackhole options on "ip route" vty commands.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28 05:07:51 +02:00
David Lamparter
fd36be7e15 zebra: rib: use nexthop ptr in rib_add/delete
This simplifies the API for the following blackhole rework.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28 04:17:22 +02:00
Renato Westphal
0af35d90a1 *: fix assorted issues detected by Coverity Scan
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-24 21:49:39 -03:00
Mitesh Kanjariya
71349e0358 zebra: lookup link by ifindex
Frr has an assumption that when interface A links to B,
we already know about B. But that might be true always.
It is probably purely depends on the configuration
and how the interfaces are hashed in Kernel.
FRR seems to sometimes get "A is linked to B" before it knows about B,
in that case, the linkage between the data structure for A & B won't be proper.

Ticket: CM-17679
Review: ccr-6628
Testing: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-20 06:10:38 -07:00
Donald Sharp
f19435a8b4 zebra: Pay attention to metric from kernel
When the linux kernel adds/deletes routes, the
metric is important, but our routing protocols
add/delete in a slightly different manner,
so allow kernel metrics to match so that our
rib matches the kernel's fib.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-09 09:17:20 -04:00
David Lamparter
c053ff8bff Merge pull request #899 from donaldsharp/ETH_ALEN
Fix Crash and Convert to ETH_ALEN
2017-08-05 05:19:01 +02:00
Donald Sharp
ff8b7eb870 zebra: Switch to using ETH_ALEN
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-04 09:06:14 -04:00
Jorge Boncompte
df0b13cf23 zebra: fix compilation in 32bit platform
RTA_PAYLOAD() return value depends on the platform bits.

make[5]: Nothing to be done for 'all-am'.
Making all in zebra
  CC       rt_netlink.o
../../zebra/rt_netlink.c: In function 'netlink_macfdb_change':
../../zebra/rt_netlink.c:1695:63: error: format '%ld' expects argument of type 'long int', but argument 7 has type 'unsigned int' [-Werror=format=]
    "%s family %s IF %s(%u) brIF %u - LLADDR is not MAC, len %ld",
                                                               ^
../../zebra/rt_netlink.c: In function 'netlink_ipneigh_change':
../../zebra/rt_netlink.c:2024:57: error: format '%ld' expects argument of type 'long int', but argument 6 has type 'unsigned int' [-Werror=format=]
      "%s family %s IF %s(%u) - LLADDR is not MAC, len %ld",
                                                         ^

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-04 10:19:36 +02:00
Donald Sharp
0ecfe5bf38 Merge branch 'master' into PIM_VRF 2017-08-02 09:39:38 -04:00
David Lamparter
ddfeb48652 build: zebra: remove *_method Makefile hacks
replace with preprocessor checks in source files.  Much simpler...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-31 23:03:30 +02:00
Donald Sharp
bd8b9272b4 zebra: Convert get_stats to use new kernel interface
Convert the XXX_get_stats functions to use the new
kernel interface.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:52:57 -04:00
Donald Sharp
e0ae31b886 lib, pimd, zebra: Allow pim to set pimregX into appropriate vrf
The pimregX devices when created by the kernel are put into
the default vrf.  When pim gets the callback that the device
exists, check to see if it is a pimregX device and if so
move it into the appropriate vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:39 -04:00
Donald Sharp
43b5cc5ee6 zebra: Allow S,G lookup to use RTNL_FAMILY_IPMR
This current implementation unfortunately must
ask the kernel for all mroutes because vrf's
do not have the ability to request a single
mroute at this time.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:39 -04:00
whitespace / reindent
d62a17aede *: reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17 14:04:07 +02:00
Donald Sharp
da571b7a6c Merge remote-tracking branch 'origin/master' into evpn_plus_struct_attr 2017-07-14 08:11:05 -04:00
Donald Sharp
eef83e96f7 Merge pull request #762 from bingen/mutiple_nh_recursive_levels
Allow for more than 1 NH recursion level
2017-07-14 07:44:02 -04:00
Donald Sharp
d5424e5356 lib: Fix some defines for older platforms
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 15:07:54 -04:00
vivek
c85c03c7f9 bgpd, zebra: Support for sticky MACs
Implement support for sticky (static) MACs. This includes the following:

- Recognize MAC is static (using NUD_NOARP flag) and inform BGP
- Construct MAC mobility extended community for sticky MACs as per
RFC 7432 section 15.2
- Inform to zebra that remote MAC is sticky, where appropriate
- Install sticky MACs into the kernel with the right flag
- Appropriate handling in route selection

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 14:37:14 -04:00
vivek
2232a77c2b zebra: MAC and Neighbor (ARP/ND) handling
Implement handling of MACs and Neighbors (ARP/ND entries) in zebra:
- MAC and Neighbor database handlers
- Read MACs and Neighbors from the kernel, when needed and create
entries in zebra's MAC and Neighbor databases.
- Handle add/update/delete notifications from the kernel for MACs and
Neighbors and update zebra's database appropriately
- Inform locally learnt MACs and Neighbors to client
- Handle MACIP add/delete from client and install appriporiate entries
into the kernel
- Since Neighbor entries will be installed on an SVI, implement the
needed mappings

NOTE: kernel interface is only implemented for Linux/netlink

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 12:29:25 -04:00
vivek
13d60d351c zebra: VNI and VTEP handling
Implement fundamental handling for VNIs and VTEPs:
- Handle EVPN enable/disable by client (advertise-all-vni)
- Create/update/delete VNIs based on VxLAN interface events and inform
client
- Handle VTEP add/delete from client and install into kernel
- New debug command for VxLAN/EVPN
- kernel interface (Linux/netlink only)

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 12:26:02 -04:00
David Lamparter
21bb7c8774 Merge commit '3d22338f04d9554fa' into evpn-prep
Conflicts:
	lib/Makefile.am

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-10 22:15:19 +02:00
ßingen
8e688dbd58 Rename ALL_NEXTHOPS_RO to ALL_NEXTHOPS 2017-07-10 21:14:59 +02:00
ßingen
f9e1b38e1a Allow for more than 1 NH recursion level
Before, only one level of recursive resolution was supported.

Signed-off-by: ßingen <bingen@voltanet.io>
2017-06-28 21:32:18 +02:00
David Lamparter
e885ed85bb Merge pull request #624 "Babel"
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-13 16:11:32 +02:00
David Lamparter
5da670a08b Merge pull request #703 from donaldsharp/nl_pid
zebra: When calling netlink, set the nl_pid as appropriate
2017-06-13 10:08:43 +02:00
David Lamparter
063221b5ad Merge pull request #700 "Coverity high"
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-13 10:05:51 +02:00
David Lamparter
97bd5c48de Merge remote-tracking branch 'frr/master' into pull-624 2017-06-13 09:18:14 +02:00
Donald Sharp
a55ba23ff7 zebra: When calling netlink, set the nl_pid as appropriate
This will allow us to further know that we originated the message.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-12 13:38:51 -04:00
Donald Sharp
43cb4d1106 zebra: Fix uninitialized memory access with src_p
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-10 16:36:32 -04:00
Donald Sharp
40078ccb05 tools, zebra: Allow zebra to insert babel routes as babel
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-08 08:56:36 -04:00
Donald Sharp
1f047d8d2c tools, zebra: Fix netlink notification of who owns the routes
For NHRP, EIGRP and LDP( This is for consistency as opposed to correctness )
assign some new values to routes to be installed into the kernel
so we can know who owns them later.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-08 08:51:25 -04:00
Donald Sharp
f0f77c9a59 zebra: Refactor 'struct rib' to be 'struct route_entry'
The 'struct rib' data structure is missnamed.  It really
is a 'struct route_entry' as part of the 'struct route_node'.
We have 1 'struct route_entry' per route src.  As such
1 route node can have multiple route entries if multiple
protocols attempt to install the same route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-01 08:00:05 -04:00
Renato Westphal
6a2ef37ad0 zebra: fix installation of ipv4 labeled unicast routes
Rearrange the _netlink_route_build*() functions so the labels of the
nexthops are always installed, even for IPv4 routes with IPv6 nexthops.

Fixes Labeled Unicast with BGP Unnumbered.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-05-29 19:59:48 -03:00
Donald Sharp
66d4272752 zebra: Remove string operations from non-debug path
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-25 21:22:03 -04:00
Donald Sharp
8755598a08 zebra: Store commonly used values instead of regenerating
the ipv4_ll address used for 5549 routes does not need
to be figured out every single time that we attempt
to install/remove a route of that type.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-25 21:11:24 -04:00
vivek
289602d73d zebra: Format netlink requests correctly
When zebra issues read (GET) requests to the kernel using the netlink
interface, it is incorrect to format all of them in a generic manner
using 'struct ifinfomsg' or 'struct rtgenmsg'. Rather, messages for a
particular entity (e.g., routes) should use the corresponding structure
for encoding (e.g., 'struct rtmsg'). Of course, this has to correlate
with what the kernel expects.

In the absence of this, there is the possibility of sending extraneous
information in the request which the kernel wouldn't like.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   David Ahern <dsa@cumulusnetworks.com>
2017-05-25 10:20:03 -07:00
David Lamparter
896014f4bc *: make consistent & update GPLv2 file headers
The FSF's address changed, and we had a mixture of comment styles for
the GPL file header.  (The style with * at the beginning won out with
580 to 141 in existing files.)

Note: I've intentionally left intact other "variations" of the copyright
header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 16:37:41 +02:00
Dinesh G Dutt
23b1f33451 Add source of route as protocol string in ip route pushed into kernel
Ticket: CM-14313
Reviewed By:
Testing Done: bgpmin, ospfmin, bgp_kitchen_sink_test

'ip route show' displays all routes as belonging to protocol zebra.
The user has to run an additional command (in vtysh) to get the actual
source of a route (bgp/ospf/static etc.). This patch addresses that by
pushing the appropriate protocol string into the protocol field of the
netlink route update message. Now you can see routes with the correct
origin as well as filter on them (ip route show proto ospf).

'ospf' is used for both IPv4 and IPv6 routes, even though the OSPF
version is different in both cases.

Sample output (old):
9.9.12.13 via 69.254.2.38 dev swp3.2  proto zebra  metric 20
9.9.13.3  proto zebra  metric 20
        nexthop via 69.254.2.30  dev swp1.2 weight 1
        nexthop via 69.254.2.34  dev swp2.2 weight 1
        nexthop via 69.254.2.38  dev swp3.2 weight 1

Sample output (new):
9.9.12.13 via 69.254.2.38 dev swp3.2  proto bgp  metric 20
9.9.13.3  proto bgp  metric 20
        nexthop via 69.254.2.30  dev swp1.2 weight 1
        nexthop via 69.254.2.34  dev swp2.2 weight 1
        nexthop via 69.254.2.38  dev swp3.2 weight 1
2017-04-20 21:24:31 -04:00
Donald Sharp
7e2b760345 *: Remove non-vrf based ifindex lookup
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:26:53 -04:00
Renato Westphal
83456d1438 Merge pull request #233 from donaldsharp/ecmp1
bgpd, zebra: Allow setting ecmp from daemon cli
2017-03-03 12:42:52 -03:00
Donald Sharp
2f8685a255 zebra: Allow multiple rib deletes from linux kernel
The kernel can send a DELROUTE with a individual
nexthop.  Technically this is meant to delete that
individual nexthop from the route but zebra
has no way to do this currently.  So we just delete
the route.

V4 -> Never sends a DELROUTE with multiple nexthops
as a way to modify the rib.  It sends a a NEWROUTE
with RTM_REPLACE with the new appropriate route.

V6 -> Sends a DELROUTE with multiple nexthops
which is supposed to be interpreted as a
subtraction from the route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-01 08:30:55 -05:00
Donald Sharp
a2ca67d1d2 zebra: Add multipath parsing to V6
In the near future it will be possible to recieve v6 multipath netlink
messages.  This code change is in prep for it.  In the meantime the
v6 code path will continue to work as per normal.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-01 08:30:50 -05:00
Donald Sharp
89a9069abb zebra: Refactor netlink_route_change and netlink_route_change_read_unicast
These two functions were basically the same.  Refactor to be
one function.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-01 08:08:05 -05:00
Donald Sharp
936ebf0a2d zebra: Add knowledge of whether or not we are acting under startup conditions
The reading if unicast routes from the kernel acts subtly differently
between reading in the routes from the kernel on startup and
reading a new route or getting a response for a route.

Add startup flag(currently ignored) so that we can start
consolidating the functionality.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-01 08:08:05 -05:00
Donald Sharp
37fe77317c bgpd, zebra: Allow setting ecmp from daemon cli
When starting up bgp and zebra now, you can specify
-e <number> or --ecmp <number>
and that number will be used as the maximum ecmp
that can be used.

The <number specified must be >= 1 and <= MULTIPATH_NUM
that Quagga is compiled with.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-01 07:58:32 -05:00
Donald Sharp
1a35e2e565 Merge remote-tracking branch 'origin/stable/2.0' 2017-02-02 10:42:51 -05:00
David Lamparter
3cb50bf1ee Revert "*: Add source of route as protocol string in ip route pushed into kernel"
This reverts commit 1a11782c40.

The change is not suitable for stable/2.0, it's not a bugfix and has
quite a visible user impact.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-31 13:51:27 +01:00
Don Slice
659b52a845 zebra: send ipv4 singlepath delete messages to kernel without nexthop
Problem reported was stale routes left in the kernel in certain cases
when overlapping static routes were used and links were bounced.  The
problem was determined to be an issue where the nexthop was changed
due to recursion as the link is going down, and the next-hop at the
time of deletion doesn't match what was previously installed by the
kernel.  This caused the kernel to reject the deletion and the route
stuck around.

It was pointed out that the kernel doesn't actually require a next-hop
value on the netlink deletion call.  In this fix, we are eliminating
the nexthop for RTM_DELROUTE messages to the kernel in the ipv4 singlepath
case.  This approach could also be valid for other cases but the fix
as is resolved the reported failure case.  More testing should be
performed before similar changes are made for other cases.

Testing included manual testing for the failure condition as well as
complete bgp-smoke and ospf-smoke tests with no new failures.

Ticket: CM-13328
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: CCR-5562
2017-01-30 13:40:53 -05:00
Dinesh G Dutt
1a11782c40 *: Add source of route as protocol string in ip route pushed into kernel
Ticket: CM-14313
Reviewed By:
Testing Done: bgpmin, ospfmin, bgp_kitchen_sink_test

'ip route show' displays all routes as belonging to protocol zebra.
The user has to run an additional command (in vtysh) to get the actual
source of a route (bgp/ospf/static etc.). This patch addresses that by
pushing the appropriate protocol string into the protocol field of the
netlink route update message. Now you can see routes with the correct
origin as well as filter on them (ip route show proto ospf).

'ospf' is used for both IPv4 and IPv6 routes, even though the OSPF
version is different in both cases.

Sample output (old):
9.9.12.13 via 69.254.2.38 dev swp3.2  proto zebra  metric 20
9.9.13.3  proto zebra  metric 20
        nexthop via 69.254.2.30  dev swp1.2 weight 1
        nexthop via 69.254.2.34  dev swp2.2 weight 1
        nexthop via 69.254.2.38  dev swp3.2 weight 1

Sample output (new):
9.9.12.13 via 69.254.2.38 dev swp3.2  proto bgp  metric 20
9.9.13.3  proto bgp  metric 20
        nexthop via 69.254.2.30  dev swp1.2 weight 1
        nexthop via 69.254.2.34  dev swp2.2 weight 1
        nexthop via 69.254.2.38  dev swp3.2 weight 1

Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2017-01-30 13:40:53 -05:00
Christian Franke
0573778371 zebra: add srcdest support to rib
Add srcdest support to the zebra rib and to the kernel
and redistribution interfaces.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-01-30 13:54:46 +01:00
David Lamparter
3c7c91d0bd zebra: receive ZAPI IPv6 source prefix
Check and read the IPv6 source prefix on ZAPI messages, and pass it down
to the RIB functions (which do nothing with it yet.)  Since the RIB
functions now all have a new extra argument, this also updates the
kernel route read functions to supply NULL.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-30 13:47:04 +01:00
Donald Sharp
1498c0593a zebra: Allow the collection of sg stats on more platforms.
The code to collect the sg stats was written for linux.
Abstract the call to allow it to work on all platforms.
I have not implemented the call for non-linux systems.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-17 22:01:36 -05:00
Donald Sharp
b58ed1f8a8 Merge remote-tracking branch 'origin/master' into pim_lib_work2 2017-01-17 21:01:56 -05:00
Donald Sharp
56c1f7d852 frr: Remove HAVE_IPV6 from code base
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-13 08:05:50 -05:00
Donald Sharp
113db9450e zebra: LastUsed needs to be updated properly.
The change to allow 12.04 to work killed S,G age out.

Put it back.

Ticket: CM-13879
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:18 -05:00
Donald Sharp
52d8f0d84f zebra: Cleanup compile for older linux platforms.
Allow code to compile for older platforms.

Ticket: CM-13745
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:17 -05:00
Donald Sharp
f0242f68c9 zebra: Fix clang SA warnings
The mr value was not being initialized to anything
and as such could contain garbage.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:15 -05:00
Donald Sharp
82d64e8ef4 zebra: Fix up the debug for receiving multicast routes
Improve the netlink debug message.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:10 -05:00
Donald Sharp
e3be04328f lib, pimd, zebra: Allow pimd to ask the kernel about mroute info
When we need to lookup the mroute info for a route.  Allow
pimd to ask the kernel.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:06 -05:00
Donald Sharp
90d82769a8 zebra: Fully decode mcast messages
Fully decode mcast messages from the kernel.  We are not
doing anything with this at the moment, but that will
change.

Additionally convert over to using lookup for
displaying the route type.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:06 -05:00
Donald Sharp
856eb2535b zebra: Allow netlink_talk to choose the filter function to call
The netlink_talk call sends a message to the kernel, which
with netlink_talk_filter only waits for the ACK.

It would be nice to have the ability to specify what the handler
function would be for when we send queries about mcast S,G routes
so that we can gather the data returned from the kernel.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:06 -05:00
Donald Sharp
565fdc7525 zebra: Remove unused variable.
Remove the rtnh variable since it is unused.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:05 -05:00
David Lamparter
53dc2b05c7 Merge branch 'stable/2.0'
Conflicts:
	bgpd/bgp_route.c
	lib/if.c
	ripd/rip_interface.c
	zebra/interface.c
	zebra/zebra_vty.c
2016-12-05 19:48:38 +01:00
Renato Westphal
661512bf05 zebra/lib: remove redundant fields from zebra_vrf
There's no need to duplicate the 'vrf_id' and 'name' fields from the 'vrf'
structure into the 'zebra_vrf' structure. Instead of that, add a back
pointer in 'zebra_vrf' that should point to the associated 'vrf' structure.

Additionally, modify the vrf callbacks to pass the whole vrf structure
as a parameter. This allow us to make further simplifications in the code.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:18:35 -02:00
Renato Westphal
1a1a70655c lib: convert vrf code to use red-black trees as well
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:18:35 -02:00
Quentin Young
0a538fc98f Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	isisd/isis_routemap.c
	zebra/rt_netlink.c
2016-10-20 16:31:49 +00:00
Timo Teräs
be717a0af8 zebra: kernel interface simplification
[DL: picked out from: "atomic FIB updates"]

This simplifies the OS-specific route update API into a single entry
point, kernel_route_rib(), which dispatches the various operations
internally.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2016-10-18 08:36:21 -04:00
Quentin Young
e52702f29d Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	bgpd/bgp_route.c
	bgpd/bgp_routemap.c
	bgpd/bgp_vty.c
	isisd/isis_redist.c
	isisd/isis_routemap.c
	isisd/isis_vty.c
	isisd/isisd.c
	lib/command.c
	lib/distribute.c
	lib/if.c
	lib/keychain.c
	lib/routemap.c
	lib/routemap.h
	ospf6d/ospf6_asbr.c
	ospf6d/ospf6_interface.c
	ospf6d/ospf6_neighbor.c
	ospf6d/ospf6_top.c
	ospf6d/ospf6_zebra.c
	ospf6d/ospf6d.c
	ospfd/ospf_routemap.c
	ospfd/ospf_vty.c
	ripd/rip_routemap.c
	ripngd/ripng_routemap.c
	vtysh/extract.pl.in
	vtysh/vtysh.c
	zebra/interface.c
	zebra/irdp_interface.c
	zebra/rt_netlink.c
	zebra/rtadv.c
	zebra/test_main.c
	zebra/zebra_routemap.c
	zebra/zebra_vty.c
2016-10-17 23:36:21 +00:00
vivek
1fdc9eae2d zebra: Refactor netlink interactions
Separate core netlink functions and library functions from route-related
interactions and interface-related interactions.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>

Ticket: CM-13199
Reviewed By: CCR-5254
Testing Done: bgp-min, ospf-min
2016-10-17 12:39:55 -07:00
vivek
4deabffba5 zebra: Derive VRF Id for slave interfaces correctly
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>

Ticket: CM-13195
Reviewed By: CCR-5250
Testing Done: Manual

<DETAILED DESCRIPTION (REPLACE)>
2016-10-14 16:02:37 -07:00
vivek
d552ed0671 zebra: Ensure correct use of VRF ID versus NS ID
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-13194
Reviewed By: CCR-5248
Testing Done: None (trivial)

<DETAILED DESCRIPTION (REPLACE)>
2016-10-14 15:54:22 -07:00
vivek
a9926e495f zebra: Clear off pointer array into which netlink attributes are parsed
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>

Ticket: CM-13018
Reviewed By: CCR-5237
Testing Done: None
2016-10-13 18:21:49 -07:00
Daniel Walton
590ef61970 zebra: Fix signed / unsigned build error
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-13 13:43:12 +00:00
Donald Sharp
353190c1c8 zebra: Fix signed / unsigned comparisons
clang is complaining about signed/unsigned comparisons
for rta_addattr_l.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-11 08:21:41 -04:00
Daniel Walton
5e6a74d811 all: removed all DEFUN command stomps (fix build errors)
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-10-06 20:23:13 +00:00
Donald Sharp
877a0aba09 Revert "zebra: use link scope for interface routes"
This reverts commit 72f3a8fb09.
2016-09-23 12:11:09 -04:00
Timo Teräs
72f3a8fb09 zebra: use link scope for interface routes
In linux, 'scope' is a hint of distance of the IP. And this is
evident from the fact that only lower scope can be used as recursive
via lookup result. This changes all interface routes scope to link
so kernel will allow regular routes to use it as via. Then we do
not need to use the 'onlink' attribute.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2016-09-23 09:51:56 -04:00
Renato Westphal
be0dba358f mpls: add null driver
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-09-23 09:31:13 -04:00
vivek
27559ebdeb MPLS: Fix pointer manipulation when forming netlink nested attributes
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Fixes: f128f2f1f8a2fa975063dd321719607693991eb0

Ticket: CM-10506
Reviewed By: CCR-4536
Testing Done: Manual verification
2016-09-23 09:31:02 -04:00
vivek
c0f4be83a1 MPLS: Install labeled static routes
This patch installs labeled static routes in the FIB. The routes are installed
using the RTA_ENCAP (and RTA_ENCAP_TYPE) nested attributes.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-6040
Reviewed By: CCR-3091
Testing Done: Tested in SE-1, brief manual testing now
2016-09-23 09:31:02 -04:00
vivek
40c7bdb0c9 Quagga: Install label forwarding entries for statically configured LSPs
Install the statically configured LSPs into the FIB (kernel). This is done
using the new attributes and definitions for MPLS in the kernel -
RTA_VIA, RTA_NEWDST and AF_MPLS.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket:  CM-4804
Reviewed By: CCR-3088
Testing Done: Manual in SE-1
2016-09-23 09:30:56 -04:00
vivek
24a7c906dc Quagga: Fix alignment in netlink messages in some cases
The alignment of nlmsg_len is calculated wrong leading to wrong rta_len
calculations for nested TLVs when the data length of the last TLV added
to the nested TLV is not aligned to RTA_ALIGNTO already. Use same fix
that was implemented in iproute2 by Thomas Graf circa 2005. A reference
to the fix is at
http://oss.sgi.com/archives/netdev/2005-03/msg03103.html.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-6491
Reviewed By: CCR-3087
Testing Done: MPLS testing with other patches in SE-1

Note: Prior to MPLS, we didn't face this problem as we haven't really had
any nested TLVs; even if RTA_MULTIPATH were to be considered a nested TLV,
it didn't have any non-aligned fields.
2016-09-23 09:30:55 -04:00
David Lamparter
4a1ab8e405 *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs
This is a rather large mechanical commit that splits up the memory types
defined in lib/memtypes.c and distributes them into *_memory.[ch] files
in the individual daemons.

The zebra change is slightly annoying because there is no nice place to
put the #include "zebra_memory.h" statement.

bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the
library for its own use.  This is bad practice and would break when the
memtype are made static.

Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
[CF: rebased for cmaster-next]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-19 16:31:04 -04:00
Timo Teräs
8ccc7e802b lib, zebra: unify link layer type and hardware address handling
This removes the BSD specific usage of struct sockaddr_dl
hardware address. This unifies to use explict hw_addr member for
the address, and zebra specific enumeration for the link layer
type.

Additionally the zapi is updated to never send platform specific
structures over the wire, but the ll_type along with hw_addr_len
and hw_addr are now sent for all platforms.

Based on initial work by Paul Jakma.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Author:    Timo Teräs <timo.teras@iki.fi>
#
# rebase in progress; onto 9c2f85d
# You are currently editing a commit while rebasing branch 'renato' on '9c2f85d'.
#
# Changes to be committed:
#	modified:   isisd/isis_circuit.c
#	modified:   lib/if.c
#	modified:   lib/if.h
#	modified:   lib/zclient.c
#	modified:   zebra/interface.c
#	modified:   zebra/interface.h
#	modified:   zebra/kernel_socket.c
#	modified:   zebra/rt_netlink.c
#	modified:   zebra/rtadv.c
#	modified:   zebra/zserv.c
#
# Untracked files:
#	"\033\033OA\033OB\033"
#	0001-bgpd-fix-build-on-Solaris.patch
#	ldpd/
#	redhat/ldpd.init
#	redhat/ldpd.service
#	tags
#
2016-09-03 11:05:50 -04:00
Donald Sharp
b4c034b033 zebra: refactor rib_add_ipv[4|6]_multipath
The rib_add_ipv[4|6]_multipath functions are functionally
equivalent.  Refactor to 1 function.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-01 07:20:18 -04:00
Donald Sharp
3b1098beed zebra: Refactor rib_add_ipv[4|6] to a common function
rib_add_ipv[4|6] both were essentially the same function
combine and refactor everywhere.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-01 07:20:18 -04:00
Donald Sharp
616368ed1e zebra: Refactor rib_delete_ipv[4|6]
These two functions are essentially the same.
Refactor.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-01 07:20:18 -04:00
Timo Teräs
c50ca33acf zebra: implement per-route mtu handling
This commits allow overriding MTU using netlink attributes on
per-route basis. This is useful for routing protocols that can
advertice prefix specific MTUs between routers (e.g. NHRP).

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
(cherry picked from commit b11f3b54c842117e22e2f5cf1561ea34eee8dfcc)
2016-08-21 13:11:42 -04:00
Paul Jakma
b892f1ddfe *: use an ifindex_t type, defined in lib/if.h, for ifindex values
(cherry picked from commit 9099f9b2a66e86f8a90d7fe18f61bd2bb1bc6744)
2016-08-18 07:35:38 -04:00
Donald Sharp
e33efc8aa8 zebra: Fix usage of accidental NULL pointer
NS_DEFAULT is #defined to 0, We are passing it
in to a function that is taking 'struct zebra_ns *'
which is translating into a NULL pointer.  Which
in some situations will cause a crash.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
             Daniel Walton <dwalton@cumulusnetworks.com>
             Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

(cherry picked from commit 1e9fa2763953adc603c3acc4ed2a46c9e72cbb29)
2016-08-15 12:10:00 -04:00
Renato Westphal
6b8a5694d3 zebra: create an abstraction layer for netlink_neigh_update()
We shouldn't have platform-agnostic code (e.g. zebra/interface.c)
calling platform-specific functions (e.g. netlink_neigh_update).

This commit introduces the kernel_neigh_update() function, which then
has to be implemented by all supported platforms. Currently only Linux
implements this function, which is only used by the RTADV code.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-08-07 21:05:26 -04:00
Renato Westphal
1bb6e9b7fa zebra: replace __u32 with standard uint32_t
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-08-07 21:05:26 -04:00
Don Slice
3f6d6a5db8 zebra/ospf/ospf6: Fix several memory leaks on if up/down
Resolved several memory leaks caused by ifdown/ifup the vrf device or
a swp port.  For bgp/zebra/ospf/ospf6, bouncing the vrf device would cause
a linked list, Interface, and route-table to get leaked.  For ospf6,
bouncing the swp device also caused leaks of Connected and Prefix entries.

Ticket: CM-10841
Signed-off-by: Don Slice
Reviewed-By: Donald Sharp
Testing Done: Manual testing, bgp and ospf mins passed, smokes had fewer failures than base
2016-06-28 04:52:38 -07:00
Quentin Young
556b904e5d zebra: Add debug zebra kernel msgdump functionality
Add command and associated functionality to enable dumping
raw netlink messages.

Ticket: CM-6568

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-06-21 18:55:01 +00:00
Donald Sharp
76981cd383 quagga: Allow compile time determination of v6 RR semantics
The patches to allow kernel v6 Route Replacement semantics
to work correctly are on a very recent kernel.  If you are
compiling on a linux kernel where it's broken, just
compile with --disable-rr-semantics.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-06-20 08:21:00 -04:00
Donald Sharp
4357b6617c zebra: Fix zebra to exit on recvmsg buffer overrun
When zebra receives a recvmsg buffer from the kernel
silently exit so that watchquagga will notice and then
restart zebra.

Ticket: CM-11130
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-06-10 11:18:58 -04:00
Timo Teräs
35d921cc20 zebra: use prefix2str for logging where possible
This makes code more robust, consice and readable.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit be6335d682c5ee1b6930345193eda875705fbab2)
2016-06-09 09:08:05 -04:00
Donald Sharp
82a95360cf zebra: Fix unprotected zlog_debug
Fixing an unprotected zlog_debug.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
2016-06-01 09:23:29 -04:00
Lu Feng
64fdba2ace zebra: fix rtnh_len in the rt_netlink messages for multipath case
In _netlink_route_build_multipath():
- Each time when appending a IPv4 gateway in the message, rtnh_len
  is increased by sizeof (struct rtattr) + 4, where we should use
  "bytelen" instead of the hard coding "4".
- As what done for IPv4, we should increase rtnh_len accordingly
  along with adding a IPv6 gateway, or else the IPv6 gateways will
  be lost.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 621e2aaf33d8ab73bf44b0eea3f3900135d34996)

Conflicts:
	zebra/rt_netlink.c
2016-05-26 17:13:49 +00:00
Daniel Walton
29d03d081e zebra: remove netlink_route() it is no longer used
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-05-26 15:25:13 +00:00
David Lamparter
9e3a437b02 zebra: remove kernel_delete_ipv6_old()
The only user of this was rib_bogus_ipv6(), which was removed in the
previous commit.  Good riddance.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Acked-by: Greg Troxel <gdt@ir.bbn.com>
Acked-by: Feng Lu <lu.feng@6wind.com>
Acked-by: Paul Jakma <paul@jakma.org>
(cherry picked from commit 51bdebad99fe813d1b7104543b352f0e39b1c8dc)
2016-05-26 15:25:13 +00:00
radhika
567b877d7f zebra - BFD client de-registration support
CM-10680
Issue: When BGP daemon is stopped, all the BGP BFD sessions are not getting deleted from PTM.
Root cause: BGP daemon stop causes BFD de-register message to be sent for every peer on which BFD is enabled. But, all the de-register messages from bgpd to zebra are not processed before the socket close. This results in some stale BGP BFD sessions.
Fix: Support for client de-register message has been added in PTM/BFD.  Changes in Quagga to support BFD client de-registrations:
−   The BFD clients de-registration is sent directly from zebra daemon when zebra client (bgpd, ospfd and ospf6d) socket close is detected.
−   Introduced a BFD flag for the zebra clients to prevent BFD de-registration messages from being sent to zebra daemon when the client is shutting down. This reduces the BFD messaging.

CM-10540
Issue: Invalid ptm status “fail” instead of “n/a” being displayed for VRF interfaces.
Root cause: ptm status is not being initialized to “unknown” status when VRF interface is added or changed. The uninitialized value is ‘0’ which is the value for “fail”
Fix: Initialized the ptm status to the correct value.

Signed-off-by: Radhika Mahankali <radhika@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Kanna Rajagopal <kanna@cumulusnetworks.com>

Ticket: CM-10680, CM-10540
Reviewed By: CCR-4653
Testing Done: PTM smoke, BGP smoke and ptmd_test.py:TestMultipleAddrsIntfOspfBgp
2016-05-08 20:11:18 -07:00
vivek
4a04e5f796 BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.

To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.

Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.

BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 13:53:38 -07:00
vivek
3e5c6e00cb zebra: Implement recovery for route install failure
Quagga does not have proper recovery for route install failure (in
the kernel). The lack of this may not be a significant issue if the
failure is only an exception. However, the introduction of route
replace presents a new failure scenario which was not there earlier.
Before replace, the update operation involved a delete followed by
add; the failure of add would not leave hanging route entries in the
kernel as they would've got deleted first. With route replace, if
the replace fails, recovery action to delete the route is needed, else
the route remains hanging in the kernel.

In particular, with VRFs and in the presence of ECMP/multipath, a
failure mode exists where Quagga thinks that routes have been cleaned
up and deleted from the kernel but the kernel continues to retain them.
This happens when multiple VRF interfaces are moved from one VRF to
another.

This patch addresses this scenario by implementing proper recovery for
route install failure.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Dinesh Dutt <ddutt@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-10361
Reviewed By: CCR-4566
Testing Done: bgp-min, ospf-min, bgp-smoke, ospf-smoke and manual

Note: There are some test failures and results aren't consistent across
runs; Daniel has resolved many of these through other fixes.
2016-04-28 22:09:17 -07:00
Donald Sharp
75f1349106 quagga: Check for existence of IFLA_INFO_SLAVE_KIND
IFLA_INFO_SLAVE_KIND is a new type of netlink message
If the kernel makes it available compile in support
else we'll just silently do the right thing.

Additionally reduce the test cases for netlink by 1
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: David Ahern <dsa@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-04-15 15:07:59 -04:00
Donald Sharp
7c5519562e zebra: Refactor zebra_vrf
Move zebra_vrf_XXX functionality into it's own
file so that we can isolate a bit the api edges

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-04-14 20:57:04 -04:00
Donald Sharp
fe18ee2d44 lib, zebra: Rework zebra_ns to be a bit more modular
The struct zebra_ns was littered throughout the code
base in a half-hazard fashion.  Gather up the references
and isolate the code a bit better.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-04-14 20:56:57 -04:00
Donald Sharp
44e9909db4 zebra: Refactor struct zebra_t
We were including 'extern struct zebra_t zebrad;' all
over the place.  This made no sense.  Refactor
into zserv.h where the definition was and remove resulting
unnecessary code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-04-14 20:56:45 -04:00
Donald Sharp
e2b1be648d lib, zebra: Rework vrf_add_update
The vrf_add_update function does not need to exist.
Move it's constituent parts into the appropriate
vrf_create/vrf_enable functionality as well as
move the zebra_vrf_add_update() function call
into zebra_vrf_enable()

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-04-14 20:56:43 -04:00
Donald Sharp
e74f14fc79 lib, zebra: Rearrange vrf_delete_update
vrf_delete_update really belongs in vrf.c broken up
into it's appropriate places.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-04-14 20:56:12 -04:00
Donald Sharp
6c12c8ab76 zebra: Fix Startup with > 1k interfaces
Zebra in rt_netlink.c has a while (1) loop that handles
recvmsg from the netlink socket.  In early bootup a
situation can occur whereby the netlink messages
take a long time to parse.  This time starts to
take an exponential amount of time the more netlink
messages that you read in.  There reaches
a point where the incoming netlink messages are
coming in at about the same rate that they are processed.
This ends up causing the while (1) loop to never exit.
Eventually this causes quagga to fail when the watchdog message
is never sent to systemd.

This patch attempts to address this deficiency in that
we allow for a pause from reading in netlink messages
to allow other work to be done.  This pause drains
the work queue items created by the netlink received
data and allows zebra to respond to other system input.

I believe we will need to come back in and modify zebra
startup a bit more.  There are ineffiencies that need
to be addressed as part of boot up.

Ticket: CM-9992
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
2016-03-31 08:20:53 -04:00
vivek
ca46a78e87 Zebra: Fix handling of larger table-ids
Zebra code was not handling larger table-ids correctly. There were 2 issues:

a) In the netlink interface, RTA_TABLE was never sent or processed. This
pretty much limited the table-ids that zebra could understand to < 255.

b) In the interface into the zebra RIB (in particular for protocols), there
were some incorrect checks that again assumed the table id should be < 252
or be "main". This is valid only for the Default VRF (for now), for other
VRFs, the table-id should be the value learnt from the kernel.

These two issues are addressed with this change.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>

Ticket: CM-10087, CM-10091
Reviewed By: CCR-4359
Testing Done: Manual
2016-03-24 22:38:40 -07:00
Donald Sharp
2878e4dff6 zebra: Some small modifications to actually delete the vrf
zebra was not actually deleting the vrf passed in.

Ticket: CM-9412
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-03-23 05:30:08 -07:00
vivek
c23af4d3e6 Zebra: Restrict IPv6 RA to valid interfaces
Restrict interfaces on which IPv6 Router Advertisements are allowed. The list
excludes loopback interfaces including the VRF device interface; specific to
Cumulus, it also includes "switch0" and "ethX" interfaces.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>

Ticket: CM-9849
Reviewed By: CCR-4334
Testing Done: Manual
2016-03-22 16:52:35 +00:00
Daniel Walton
c5344534ff quagga: Netlink error message following Notification send
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Vivek Venkatraman <vivek@cumulusnetworks.com>

Ticket: CM-9501
2016-03-16 20:56:15 +00:00
vivek
5b5b953fbd Quagga: Implement VRF change semantics for an interface
Invoke VRF change for an interface, if appropriate, upon netlink
notification.

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
2016-02-25 19:41:01 +00:00
Don Slice
e186aa9ffa Zebra: Enable VRF as an interface creation
Modified response to netlink message for VRF creation, allowing it to be
created as an interface and setting the right vrf_id and bringing in the ip address.

Ticket: CM-9277
Signed-off-by: Don Slice
Reviewed-by: Vivek Venkatraman
2016-02-22 21:39:06 +00:00
vivek
e786b6015e Zebra: Fix ignoring status for VRF device
The earlier change to ignore status for VRF device was not quite perfect. As
defect CM-9437 illustrates, there are situations when Quagga may get a VRF
member interface (that refers to the VRF id of the VRF device) before it gets
the VRF device itself. The code has some logic to handle this, creating a
VRF structure which is partly initialized. The initialization is completed
with some additional incorrect status processing when the VRF is learnt. The
fix done earlier completely ignored the VRF message treating it as a status
change because the VRF is already present, but this left the VRF structure
not fully initialized in Quagga. The fix is to do some additional checks
to handle this scenario.

Fixes: 3e66be2ee6

Ticket: CM-9437
Reviewed By: None
Testing Done: Reproduced problem, verified fix.
2016-02-22 05:33:46 +00:00
vivek
3e66be2ee6 Zebra: Ignore status change for VRF (temporary)
Temporary change to ignore status change for a VRF device as it is
incorrectly implemented now. When VRF is also supported as an
interface, the status change will be handled for the interface.

Ticket:
Reviewed By:
Testing Done:
2016-02-19 22:50:56 -08:00
vivek
c3c06a51aa Zebra: Tweak netlink socket creation function
Since the netlink socket is per namespace and not per VRF, do not
invoke vrf_socket().

Note: This needs to be changed when we support multiple namespaces -
needed only for upstreaming.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-9206
Reviewed By: CCR-4127
Testing Done:
2016-02-19 14:18:35 -08:00
Don Slice
498d2f9963 Zebra: Fix vrf setting based on netlink messages
Adjusted application of vrf_id as interfaces are handled via netlink message.

Ticket: CM-9278
Signed-off-by: Don Slice
Reviewed-by: Donald Sharp
2016-02-19 19:31:16 +00:00
vivek
30a3822f2b Zebra: Restrict automatic RA enable to relevant interfaces
When enabling IPv6 Router Advertisements automatically based on the
presence of IPv6 address on an interface, do it only for relevant
interfaces.

Note: This needs a configure option for completion.

Ticket: CM-9358
Reviewed By: CCR-4116
Testing Done: Manual verification
2016-02-18 18:47:32 -08:00
Don Slice
be08f6780b zebra: set vrf-id on vrf slave interfaces
vrf: check netlink message for slave info and set the vrf-id accoringly

When a netlink newlink or link change comes into zebra, check the IFLA_INFO_SLAVE_KIND
to discover if the interface is a member of a vrf or not.  Set the vrf-id to the correct
value if the interface is a slave member

Signed-off-by: Don Sice
Reviewed-by:
2016-02-15 18:36:57 +00:00
sharpd
b9590d4de4 zebra: All slave devices were being treated as vrfs
When a slave device is received via netlink, all the
devices were being treated as vrf's instead of the
myriad of slave devices that are possible.

Add code to check to see if the device is truly a vrf slave
or not.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-02-10 18:41:59 -08:00
Donald Sharp
19dc275e1f lib, vtysh, zebra: Better VRF debug handling
Fixup the debug handling of vrf's to be a bit
more explicit how we create a vrf internally.

Add code to turn on/off debugging of vrf's.

Ticket: CM-9063
Testing: Manual

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-02-03 09:00:25 -05:00
Donald Sharp
12f6fb9731 lib, zebra: The Bulk of the conversion over to NS and VRF
Convert the rest of zebra over to use a Namespae and VRF.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-02-01 10:55:42 -08:00
Donald Sharp
3ee39b5ba0 ZEBRA: Remove NEXTHOP_TYPE_XXX_IFNAME
The NEXTHOP_TYPE_XXX_IFNAME types were never being used.  Remove them
and the code associated with them.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-12-04 10:44:37 -08:00
Donald Sharp
cbdee2350a Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster 2015-11-27 08:58:52 -08:00
Donald Sharp
b3d439f347 Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster 2015-11-27 08:47:38 -08:00
Donald Sharp
a399694f39 Quagga: Nexthop refactoring
Upstream wanted some nexthop code to be refactored.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-11-27 08:46:54 -08:00
Donald Sharp
4690c7d74c Quagga: prefix2str fixup
During CR for nexthop upstream it was noticed that usage
of prefix2str was not consistent.  This fixes this problem

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-11-23 13:31:11 -08:00
vivek
ce2641ee1b Zebra: Ignore bridge address family netlink notifications
Ticket: CM-8045
Reviewed By: CCR-3736
Testing Done:

This is an import of patch zebra-ignore-bridge-af.patch from 2.5-br.
2015-11-20 11:09:25 -08:00
vivek
6a3b353168 Zebra: Handle IPv6 address status during initialization
At init time, Zebra queries the kernel for all interfaces. At this time,
an IPv6 address may exist on an interface but IPv6 DAD has not completed,
or it could be that DAD has failed. Zebra should examine the flags on
the address and act accordingly. Otherwise, it may end up with addresses
and routes which are not actually valid in the kernel, and this may lead
to, for example, BGP attempting neighbor connections on an interface on
which the source IPv6 address is not yet valid.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Dinesh Dutt <ddutt@cumulusnetworks.com>

Ticket: CM-7176
Reviewed By: CCR-3815
Testing Done: Verify failed test (needs temporary test change)

Note: Imported from 2.5-br patch zebra-handle-ipv6-addr-status.patch.
2015-11-20 10:34:50 -08:00
vivek
dccc522572 Zebra: Implement route replace for IPv6
Zebra currently performs a delete followed by add when a route needs to be
modified. Change this to use the replace semantics of netlink so that the
operation can possibly be atomic.

Note: This patch handles IPv6 routes, IPv4 already performs a replace.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Dinesh Dutt <ddutt@cumulusnetworks.com>

Ticket: CM-5597
Reviewed By: CCR-3407
Testing Done: Manual testing of various scearnios (Vivek, Satish)

Note: This is an import of patch zebra-ipv6-route-replace.patch from 2.5-br.
2015-11-19 12:22:55 -08:00
Donald Sharp
7c5d2b76c6 Quagga: Set MULTIPATH_NUM to 64 when user specifies 0 from cli
The code has tests to see if the MULTIPATH_NUM == 0 and to
treat it like the user has entered 'Maximum PATHS'.
This 0 is treated as 64 internally.  Remove this dependency
and setup MULTIPATH_NUM to 64 when --enable-multipath=0 from
the configure cli.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2015-11-17 08:13:23 -08:00
Feng Lu
8f7d9fc088 zebra, lib/memtypes.c: the netlink sockets work per VRF
This patch lets the netlink sockets work per VRF.

* The definition of "struct nlsock" is moved into zebra/rib.h.

* The previous global variables "netlink" and "netlink_cmd" now
  become the members of "struct zebra_vrf", and are initialized
  in zebra_vrf_alloc().

* All relative functions now work for a specific VRF, by adding
  a new parameter which specifies the working VRF, except those
  functions in which the VRF ID can be obtained from the interface.

* kernel_init(), interface_list() and route_read() are now also
  working per VRF, and moved from main() to zebra_vrf_enable().

* A new function kernel_terminate() is added to release the
  netlink sockets. It is called from zebra_vrf_disable().

* Correct VRF ID, instead of the previous VRF_DEFAULT, are now
  passed to the functions of processing interfaces or route
  entries.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>

Conflicts:
	lib/memtypes.c
	zebra/rib.h
	zebra/rt_netlink.c

Conflicts:
	zebra/if_netlink.c
	zebra/if_sysctl.c
	zebra/kernel_null.c
	zebra/rib.h
	zebra/rt_netlink.c
	zebra/rt_netlink.h
2015-10-30 01:45:21 -07:00
Feng Lu
78104b9bad zebra: let FIB stand for its respective VRF
A new member "vrf_id" is added to "struct rib", reflecting the VRF
which it belongs to.

A new parameter "vrf_id" is added to the relative functions where
need, except those:
- which already have the parameter "vrf_id"; or
- which have a parameter in type of "struct rib"; or
- which have a parameter in type of "struct interface".

All incoming routes are set to default VRF.

In fact, all routes in FIB are kept in default VRF. And the logic
is not changed.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
[DL: conflicts fixed + compile warning fix]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

Conflicts:
	zebra/connected.c
	zebra/kernel_socket.c
	zebra/rib.h
	zebra/rt_netlink.c
	zebra/zebra_rib.c
	zebra/zserv.c

Conflicts:
	zebra/connected.c
	zebra/interface.c
	zebra/kernel_socket.c
	zebra/rib.h
	zebra/rt_netlink.c
	zebra/rtread_getmsg.c
	zebra/zebra_rib.c
	zebra/zebra_vty.c
	zebra/zserv.c
2015-10-29 23:38:03 -07:00
vivek
fb5d585cec Zebra: Fix setting source for 5549-learnt routes via ip protocol
Ticket: CM-6854
Reviewed By: CCR-3297
Testing Done: bgpsmoke, bgpclos to verify setting source (in 2.5-br)

Two pieces prevented the user from specifying a route-map with set src on
IPv4 routes learnt via BGP's RFC 5549 model (v4 prefix with v6 nexthop):
   - There was code missing in the section specific to 5549 in setting
     the src in the netlink message
   - During RIB processing, route-map processing was ignored when the NH
     was v6 and the route itself was v4.

As per the code, all route-map processing that uses nexthop validates the
NH type before applying the route-map and so there should be no errors
as a consequence of relaxing bullet 2 above.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-20 14:32:12 -07:00
Donald Sharp
6878b9db99 Warn user in various max path edge cases
Ticket: CM-6680
Reviewed-by: CCR-3486
Testing: See bug

In these situations:
(A) user enters under bgp more 'maximum-paths' than zebra is compiled with
warn the user that there is a problem
(B) Zebra receives more maximum paths than what it can handle log the fact
that this happened

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-09-16 05:30:23 -07:00
Dinesh G Dutt
0aabccc0a8 Zebra: Add IPv6 protocol filtering support & Setting Src of IPv6 routes
Ticket:
Reviewed By: CCR-3335
Testing Done: bgpsmoke, ENHE tests etc.

    Add support for filtering routes from upper layer protocols to zebra
    via route-maps for IPv6. The same functionality already existed for
    IPv4.

    In addition, add support for setting source of routes via IPv6 protocol
    map.

    Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
    Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
    Reviewed-by: Vivek Venkataraman <vivek@cumulusnetworks.com>
    Reviewed-by: Vipin Kumar <vipin@cumulusnetworks.com>
2015-09-15 23:48:00 -07:00
Donald Sharp
5c610fafc4 2015-06-11 09:19:59 -07:00
Donald Sharp
6ae24471cb Zebra: Implement route replace semantics.
Zebra currently performs a delete followed by add when a route needs to be
modified. Change this to use the replace semantics of netlink so that the
operation can possibly be atomic.

Note: Only implemented for IPv4 currently.
2015-06-11 09:11:12 -07:00
Donald Sharp
b881a42484 When an interface is disabled, a Cumulus kernel patch causes route deletes to
be issued to Quagga. Quagga will in turn try to re-add the route(s) back to
the kernel and this will result in an error back from the kernel. This change
is to make sure these error messages are not logged by default. Subsequent
changes will cleanup this handling (to address CM-4577).

Note: This patch should not be upstreamed.
2015-06-11 09:11:12 -07:00
Donald Sharp
4e3afb1472 zebra: zebra-warnings.patch
Remove compiled warnings for the zebra directory
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:
2015-05-19 18:04:26 -07:00
Donald Sharp
7a4bb9c54e zebra-redistribute-table.patch
Zebra: Redistribute routes from non-main kernel table to main.

This can be the basis for many interesting features such as variations
of redistribute ARP, using zebra as the RIB in the presence of multiple
routing protocol stacks etc. The code only supports IPv4 for now, but
the infrastructure is in place for IPv6.

Usage:
There is a new route type introduced by this model: TABLE. Routes
imported from alternate kernel tables will have their protocol type set to
TABLE.

Routes from alternate kernel tables MUST be first imported into the main
table via "ip import-table <table id>". They can then be redistributed via
a routing protocol via the "redistribute table" command. Each imported table
can an optional administrative distance specified. In Zebra, a route with a
lower distance is chosen over routes with a higher distance. So, distance
is how the user can choose to prioritize routes from a particular table over
routes from other tables or routes learnt another way in zebra.

Route maps for imported tables are specified via "ip protocol" command in
zebra. Route maps for redistributed routes within a routing protocol are
subject to the route map options supported by the protocol. The
"match source-protocol" option in route maps can match against "table"
to filter routes learnt from alternate kernel routing tables.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 18:03:42 -07:00
Donald Sharp
7c8ff89e93 Multi-Instance OSPF Summary
——————————————-------------

- etc/init.d/quagga is modified to support creating separate ospf daemon
  process for each instance. Each individual instance is monitored by
  watchquagga just like any protocol daemons.(requires initd-mi.patch).

- Vtysh is modified to able to connect to multiple daemons of the same
  protocol (supported for OSPF only for now).

- ospfd is modified to remember the Instance-ID that its invoked with. For
  the entire life of the process it caters to any command request that
  matches that instance-ID (unless its a non instance specific command).
  Routes/messages to zebra are tagged with instance-ID.

- zebra route/redistribute mechanisms are modified to work with
  [protocol type + instance-id]

- bgpd now has ability to have multiple instance specific redistribution
  for a protocol (OSPF only supported/tested for now).

- zlog ability to display instance-id besides the protocol/daemon name.

- Changes in other daemons are to because of the needed integration with
  some of the modified APIs/routines. (Didn’t prefer replicating too many
  separate instance specific APIs.)

- config/show/debug commands are modified to take instance-id argument
  as appropriate.

Guidelines to start using multi-instance ospf
---------------------------------------------

The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.

To enable multiple instances, do the following:

     1. service quagga stop
     2. Modify /etc/quagga/daemons to add instance-ids of each desired
        instance in the following format:
        ospfd=“yes"
        ospfd_instances="1,2,3"
	assuming you want to enable 3 instances with those instance ids.
     3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
        and ospfd-3.conf.
     4. service quagga start/restart
     5. Verify that the deamons are started as expected. You should see
        ospfd started with -n <instance-id> option.
     	ps –ef | grep quagga
     	With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
	ospfd-<instance-id>/vty to each instance.
     6. vtysh to work with instances as you would with any other deamons.
     7. Overall most quagga semantics are the same working with the instance
     	deamon, like it is for any other daemon.

NOTE:
     To safeguard against errors leading to too many processes getting invoked,
     a hard limit on number of instance-ids is in place, currently its 5.
     Allowed instance-id range is <1-65535>
     Once daemons are up, show running from vtysh should show the instance-id
     of  each daemon as 'router ospf <instance-id>’  (without needing explicit
     configuration)
     Instance-id can not be changed via vtysh, other router ospf configuration
     is allowed as before.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 18:03:42 -07:00
Donald Sharp
c3c0ac8395 ospf6d: ospfv3-abr-ecmp-support.patch
OSPFv3: Add ABR support and make ECMP > 4.

Signed-off-by: Dinesh G Dutt <ddutt at cumulusnetworks.com>
Signed-off-by: Pradosh Mohapatra <pmohapat at cumulusnetworks.com>
2015-05-19 18:03:39 -07:00
Donald Sharp
c52ef59fed zebra-set-src-routemap.patch
Honor setting source via route map and pushing that to the kernel.

With recursive routes, the ability to set the source IP address of a route
via a routemap has been broken. This patch fixes that.

To allow route map to set a source and then to unapply the route map and
have the source be taken out, I've introduced a new field in the nexthop
data structure called rmap_src. This field is zero'd before invoking the
route map apply function.

Today, no protocol daemon specifies the src in its route update to zebra.
If that happens, I didn't want to stomp on it and so have left the src
field intact instead of reusing that for the routemap to play with.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 17:47:24 -07:00
Donald Sharp
244c1cdce5 ptm-integration.patch
Integrates Prescriptive Topology Module(ptm) into quagga.

If this module is enabled, link ups are notified only after the link is verified
as being connected to the neighbor specified. The neighbor specification and
checking is done by the ptm daemon.
2015-05-19 17:40:44 -07:00
Donald Sharp
2037f143d8 Do not allow a program outside Quagga to delete a Quagga route from the kernel.
To delete a Quagga route, do it inside Quagga.
2015-05-19 17:40:43 -07:00
Donald Sharp
1f5705f042 zebra: zebra-use-fixed-metric-cost.patch
Zebra: Use a fixed route metric when populating kernel

The route metric is not used by the Linux kernel and is irrelevant to
the forwarding decision made by the kernel. Metric is a parameter used
only by a routing protocol to compute best path(s) and to communicate this
info to its peers. Consequently, there is no value in pushing the metric
provided by a protocol daemon to the kernel.

There is a significant advantage, at least on the Linux kernel, in pushing
a constant metric with a route populated by zebra. The metric is used as a
priority field in the kernel and modifying the metric due to say topology
changes causes multiple routes to be inserted into the kernel, with differing
priorities instead of replacing the existing one. This prevents us from
using replace semantic when a route changes.

So, this patch pushes a constant metric with a route populated by zebra.
2015-05-19 17:40:35 -07:00
Donald Sharp
fb018d251e nexthop-tracking.patch
quagga: nexthop-tracking.patch

Add next hop tracking support to Quagga. Complete documentation in doc/next-hop-tracking.txt.

Signed-off-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2015-05-19 17:40:34 -07:00
Donald Sharp
41fc27146a This patch enables support for multipath for IPV6. The nexthop information
from the protocols have ifindices and nexthop addresses in two different
structures. This patch combines them to ensure that the correct APIs can
be called. Also, given that IPV6 Linux implementation does not support the
rta_XXX APIs for multipath, the communication with the kernel is in terms
of a single nh/ifindex pair.
2015-05-19 17:24:43 -07:00
Timo Teräs
c299ed717e zebra: fix struct msghdr initializers
struct msghdr field orders are not strictly specified in POSIX.
Improve portability by using designated initializer. This fixes
build against musl c-library where struct msghdr is POSIX
compliant (Linux kernel and glibc definitions are non-conforming).

As the result is also more readable, struct iovec initilizers
were also converted.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-08-18 01:50:23 +02:00
David Lamparter
6b0655a251 *: nuke ^L (page feed)
Quagga sources have inherited a slew of Page Feed (^L, \xC) characters
from ancient history.  Among other things, these break patchwork's
XML-RPC API because \xC is not a valid character in XML documents.

Nuke them from high orbit.

Patches can be adapted simply by:
	sed -e 's%^L%%' -i filename.patch
(you can type page feeds in some environments with Ctrl-V Ctrl-L)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-06-04 06:58:02 +02:00
Michal Sekletar
8e998b1eb5 zebra: raise the privileges before calling socket()
Because of recent changes when creating AF_NETLINK socket, kernel will
cache capabilities of the caller and if file descriptor is used or
otherwise handed to another process it will check that current user has
necessary capabilities to use the socket. Hence we need to ensure we
have necessary capabilities when creating the socket and at the time we
use the socket.

See: http://www.spinics.net/lists/netdev/msg280198.html

Signed-off-by: Michal Sekletar <msekleta@redhat.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-05-27 19:50:45 +02:00
Brett Ciphery
db19c85679 zebra: set metric for directly connected routes via netlink to 0
a value of 1 is hard coded for the metric field, much like the
ifconfig utility it may have roots in.  in order to be in line
with the metric used in the linux kernel itself, we switch this
to 0.

Signed-off-by: Brett Ciphery <brett.ciphery@windriver.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-04-01 17:27:53 +02:00
Christian Franke
e8d3d2991f zebra: implement NEXTHOP_FLAG_ONLINK
On Linux, the kernel will only allow for a route to be installed when
its gateway is directly attached according the kernel fib.

There are cases when this restriction by the kernel is too strong, in
those cases, we deploy the RTNH_F_ONLINK netlink flag.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-09-19 18:04:40 +02:00
Christian Franke
fa713d9ee5 zebra: rework recursive route resolution
Change the datastructure for recursive routes. This brings the following
benefits:

By using struct nexthop also to store nexthops obtained by recursive
resolution, we can get rid of quite a bit of code duplication in the fib
management. (rt_netlink, rt_socket, ...)

With the new datastructure we can make use of all available paths when
recursive routes are resolved with multipath routes.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-09-19 18:04:40 +02:00
Christian Franke
599da95527 zebra: process information about new addresses (BZ#486)
Because of a change of semantics in the Linux kernel, information
about changes made by zebra itself was not considered for updates.
This change should fix this by accounting for the new semantics.

It is based on a patch by lich posted to the bugzilla #486

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-09-19 17:51:00 +02:00
Ulrich Weber
f1ef81b247 zebra: use SO_RCVBUFFORCE for netlink socket
so net.core.rmem_max must not be adjusted. Requires
linux kernel >= 2.6.14, falls back to SO_RCVBUF on error

Signed-off-by: Ulrich Weber <ulrich.weber@sophos.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-02-23 18:19:24 +01:00
Avneesh Sachdev
78deec450c zebra: extern/extract some functions from rt_netlink.c
* zebra/{rib.h,zebra_rib.c}

    Add nexthop_type_to_str(), which returns a human-readable string
    corresponding to a nexthop type.

  * zebra/rt_netlink.[hc]

    - Add new header file that exposes some existing and new
      netlink-related functions from rt_netlink.c to the rest of
      zebra.

        addattr32
        addattr_l
        rta_addattr_l
        nl_msg_type_to_str (new)
        nl_rtproto_to_str (new)

    - Use nexthop_type_to_str() instead of the static array
      'nexthop_types_desc'.

Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-11-30 21:41:17 +01:00
Balaji.G
837d16ccbe *: use array_size() helper macro
Use the array_size() helper macro.  Replaces several instances of local
macros with the same definition.

Reviewed-by: Scott Feldman <sfeldma@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-10-25 10:15:59 -07:00
Jorge Boncompte [DTI2]
a4c06dec1e zebra: no need to clear memory of the netlink buffers
The memory is always written before sending. Clearing it before use
slows netlink_route_multipath() down considerably and it's pretty
noticeable in a full-internet table scenario loading.

  * zebra/rt_netlink.c: subtract bulk buffer size from clear

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
[reworded commit message]
Signed-off-by: David Lamparter <equinox@diac24.net>
2012-05-02 17:03:34 +02:00
JR Rivers
3cadc0cdeb zebra: use larger buffer (4096) for netlink messages
Increase the maximum number of nexthops per route by using a larger
buffer for netlink messages.

  * zebra/rt_netlink.c: Use a buffer of 4096 bytes to parse/build
    netlink messages. Add a hash define for this number
    (NL_PKT_BUF_SIZE). Most places in the code were previously using a
    buffer of 1024 bytes.
2012-04-16 18:36:52 +02:00
Avneesh Sachdev
14d2bbaa3f Merge quagga mainline into the google ISIS code.
The steps were:

  $ git checkout google-is-is
  $ git merge quagga
  $ git checkout google-is-is -- isisd

  # Resolve conflicts in the following:
  lib/md5.h
  zebra/rt_netlink.c
  zebra/zebra_rib.c
  zebra/zserv.c

Note that the content in the isisd directory is left unchanged in the
merge. As a result, changes made to isisd as part of the following
commits on the quagga mainline are dropped.

  # 8ced4e82 is the merge base, e96b3121 is the current quagga master
  $ git log --oneline --reverse 8ced4e82..e96b3121 -- isisd
  5574999 isisd: fix crash on "no router isis" (BZ#536)
  8998075 isisd: raise hello rate for DIS (BZ#539)
  306ca83 isisd: include hash.h, not hash.c
  b82cdeb delete CVS keywords
  2f65867 isisd: indent longopts array
  b511468 quagga: option "-z" ("--socket <path>") added
  05e54ee build: delete .cvsignore files
  b4e45f6 fix zebra protocol after MP-BGP changes
  7fd6cd8 isisd: fix circuit state machine
  907fd95 isisd: send proper LSP after DIS election
  d034aa0 isisd: fix wrong next-hops from SPF
  c25eaff isisd: unexpected kernel routing table (BZ#544)
  e6b03b7 isisd: implement MD5 circuit authentication
2012-04-11 23:51:08 -07:00
Josh Bailey
26e2ae362b zebra: read multipath routes and hw addr from netlink
* zebra/rt_netlink.c:

    - Pick up the hardware address of an interface when we receive a
      netlink link change message. Extract code for parsing the
      link-layer hardware address into a new function so we can reuse
      it.

    - netlink_routing_table(): Update to handle multipath routes.

    - netlink_route_change(): Update to handle multipath routes. Fix
      problem where the metric was not being read out.

  * zebra/zebra_rib.[ch]: Extern nexthop_ipv4_ifindex_add() -- it is
    now called from the netlink code.

From: Josh Bailey <joshb@google.com>
Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@diac24.net>
2012-04-07 13:54:02 -07:00
G.Balaji
f768f367bc zebra: IPv6 MP-BGP Routes addition and deletion
This patch contains the following:
1. Addition of IPv6 SAFI_MULTICAST BGP routes into the RTM's RIB.
2. Deletion of IPv6 SAFI_MULTICAST BGP routes from the RTM's RIB.
2012-01-23 14:30:57 +04:00
G.Balaji
cddf391bf6 zebra: IPv4 MP-BGP Routes addition and deletion
This patch contains the following:
1. Addition of IPv4 SAFI_MULTICAST BGP routes into the RTM's RIB.
2. Deletion of IPv4 SAFI_MULTICAST BGP routes from the RTM's RIB.
2012-01-23 14:30:42 +04:00
Stephen Hemminger
9206f9ecd5 fix set never used warnings
(This patch was modified to leave calls to stream_getl() in place, they
are necessary for the stream's internal pointer to advance to the
correct position. -- Denis)

Signed-off-by: Denis Ovsienko <infrastation@yandex.ru>

Fix gcc warnings about varables that are set but never used.

* bgpd/bgp_attr.c
  * cluster_unintern(): ret
  * transit_unintern(): ret
  * bgp_attr_default_intern(): attre
  * bgp_mp_reach_parse(): rd_high, rd_low
* bgpd/bgp_route.c
  * bgp_announce_check_rsclient(): bgp
* bgpd/bgp_zebra.c
  * zebra_read_ipv4(): ifindex
  * zebra_read_ipv6(): ifindex
* bgpd/bgpd.c
  * bgp_config_write_peer(): filter
* lib/distribute.c
  * distribute_list_all(): dist
  * distribute_list(): dist
  * distribute_list_prefix_all(): dist
  * distribute_list_prefix(): dist
* lib/if_rmap.c
  * if_rmap(): if_rmap
* lib/vty.c
  * vty_accept(): vty
* lib/zclient.c
  * zclient_read(): ret
* zebra/irdp_interface.c
  * if_group(): zi
* zebra/rt_netlink.c
  * kernel_read(): ret, sock
2011-12-18 20:21:21 +04:00
Dmitry Popov
83d1614952 zebra: fix loss of metric for Linux routes
* rt_netlink.c
  * netlink_route_change(): fetch metric information like
    netlink_routing_table() does and pass it further
2011-09-27 20:46:25 +04:00
Mathieu Goessens
d13c3b4fcf [zebra] linux policy routing support with ipv6
Quagga support linux policy routing (ip route ... table $X) with zebra.conf
table $X option.  It works fine on ipv4.  On ipv6 the parameter is ignored
(table 0 is used).

* zebra/...: Pass appropriate table arg to rib_{add,delete}_ipv6
2009-06-23 15:59:45 +01:00
Stephen Hemminger
4308abba5c [zebra] MTU is unsigned
The MTU data in the netlink message is always unsigned 32 bits.
Don't use integer.
2009-06-18 20:18:25 +01:00
Stephen Hemminger
4c699477d2 [zebra:linux] netlink: no need to change privs for receive
2008-06-17 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* rt_netlink.c: (netlink_parse_info) Linux doesn't check privledges
	  on receive, so avoid the overhead of lowering and raising the
	  priviledges on each received message

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:56:25 +01:00
Stephen Hemminger
898987e976 [zebra:linux] netlink: quiet harmless errors
2008-06-17 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* rt_netlink.c: (netlink_parse_info) There can be harmless races
	  such as adding an existing route, or deleting an already deleted
	  route. Don't bother logging these unless debugging is turned on.

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:56:25 +01:00
Stephen Hemminger
30afea3b58 [zebra:linux] netlink buffer size tweaking only needed on receive socket
2008-08-16 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* rt_netlink.c: (netlink_recvbuf) consolidate recvbuf setting
	  (netlink_socket) no need to set receive buffer on netlink sockets
	  generally
	  (kernel_init) set recvbuffer on the listen socket

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:56:25 +01:00
Stephen Hemminger
4cde931e2d [zebra:linux] clean up blocking setting of netlink sockets
2008-08-16 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* zebra/rt_netlink.c: This change removes the overhead of twiddling
          the socket twice on every route change. The netlink support has
          two sockets, one is used for request/response and should always
          block. The other is used for asynchronous notification and should
          always be non-blocking.

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:56:25 +01:00
Stephen Hemminger
3d265b4d9d [zebra:linux] Filter out unwanted netlink messages by PID
2008-08-16 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* zebra/rt_netlink.c: Update the netlink socket BPF to cancel out
	  unwanted ACKs on the listen socket by matching on the PID.

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:56:25 +01:00
Stephen Hemminger
1423c809cc [lib] mes_lookup string lookup table argument should be marked const
2008-08-14 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* lib/log.{c,h}: struct message argument should point to const
	* */*.c: adjust to suit,

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:52:58 +01:00
Stephen Hemminger
6072b24eb7 [zebra] mark some rt_netlink functions static
2008-08-14 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* zebra/rt_netlink.c: local functions should be static.

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:52:58 +01:00
Timo Teräs
40da22166f [zebra:netlink] Set proto/scope on all route update messages
2008-08-13 Timo Teräs <timo.teras@iki.fi>

	* zebra/rt_netlink.c: (netlink_route{,_multipath) Set protocol and
	  scope appropriately for both NEW and DELROUTE messages, to avoid
	  wiping out non-zebra routes on delete.

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:52:57 +01:00
Paul Jakma
768a27ea7b [zebra/linux] Use BPF to filter out responses, to try avoid netlink overruns
2008-05-29 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* rt_netlink.c: (netlink_install_filter) BPF filter to catch and
	  drop responses to zebra's own route messages.
	  (kernel_init) add BPF filter on the netlink socket.
2008-05-29 18:23:08 +00:00
vize
068fd77cff Use the proper field length for the peer's address (netlink_interface_addr) 2007-08-10 06:25:20 +00:00
Paul Jakma
7514fb7739 [zebra] Routemap support on received routes, with 'set src' command (linux)
2007-05-01 David L Stevens <dlstevens@us.ibm.com>

	* (general) These changes collectively add route-map and
	  prefix-list support to zebra and fix a bug in "show
	  route-map" (with no argument).
	* doc/main.texi: added route-map, prefix-list, ip protocol
	  and set src documentation
	* lib/command.h: added PROTOCOL_NODE type
	* lib/log.c: (proto_name2num) new function, protocol name to
	  number translation.
	* lib/routemap.c: (vty_show_route_map) fixed "show route-map"
	  without route-map name
	* lib/routemap.h: added RMAP_ZEBRA type
	* lib/zebra.h: added proto_name2num() prototype
	* vtysh/extract.pl.in: added VTYSH_ZEBRA flag for route-map and
	  plist
	* vtysh/Makefile.am: added zebra_routemap.c
	* vtysh/vtysh.h: added VTYSH_ZEBRA flag to VTYSH_RMAP
	* zebra/connected.c: (connected_up_ipv4) added src preference argument
	  to rib_add_ipv4()
	* zebra/kernel_socket.c: (rtm_read) ditto
	* zebra/main.c: added prefix list initialization
	* zebra/Makefile.am: added zebra_routemap.c source file
	* zebra/rib.h: added generic address union "g_addr" and use in
	  existing places that had an explicit union.
	  Added "src" to struct nexthop.
	  Added preferred src arg to nexthop_ipv4_add and rib_add_ipv4.
	* zebra/rt_netlink.c: (netlink_routing_table) set preferred source on
	  netlink messages.
	  (netlink_route_change) ditto
	  (netlink_route_multipath) ditto.
	* zebra/rtread_getmsg.c: (handle_route_entry) added (NULL) src to
	  rib_add_ipv4() call.
	* zebra/rtread_proc.c: (proc_route_read) ditto
	* zebra/zebra_rib.c: (nexthop_ipv4_add) add src argument.
	  (nexthop_ipv4_ifindex_add) ditto
	  (rib_add_ipv4) ditto
	  (nexthop_active_check) Add route-map processing.
	* zebra/zebra_routemap.c: new file for zebra route-map commands.
	* zebra/zebra_vty.c: (ip_protocol_cmd) Apply route-map to protocol
	  (vty_show_ip_route_detail) added "src" printing
	  (vty_show_ip_route) ditto
	  (show_ip_protocol_cmd) new command, list routemaps.
	  (config_write_protocol) write out routemap protocl config.
	  (zebra_vty_init) Install the new routemap protocol commands.
	* zebra/zserv.c: (zread_ipv4_add) added (NULL) src arg
	  (zebra_init) init zebra route-maps.
	* zebra/zserv.h: add zebra_route_map_init
2007-05-02 16:05:35 +00:00
Andrew J. Schorr
e4529636b7 [PtP over ethernet] New peer flag allows much more addressing flexibility
2006-12-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

	* if.h: (struct connected) Add new ZEBRA_IFA_PEER flag indicating
	  whether a peer address has been configured.  Comment now shows
	  the new interpretation of the destination addr: if ZEBRA_IFA_PEER
	  is set, then it must contain the destination address, otherwise
	  it may contain the broadcast address or be NULL.
	  (CONNECTED_DEST_HOST,CONNECTED_POINTOPOINT_HOST) Remove obsolete
	  macros that were specific to IPv4 and not fully general.
	  (CONNECTED_PEER) New macro to check ZEBRA_IFA_PEER flag.
	  (CONNECTED_PREFIX) New macro giving the prefix to insert into
	  the RIB: if CONNECTED_PEER, then use the destination (peer) address,
	  else use the address field.
	  (CONNECTED_ID) New macro to come up with an identifying address
	  for the struct connected.
	* if.c: (if_lookup_address, connected_lookup_address) Streamline
	  logic with new CONNECTED_PREFIX macro.
	* prefix.h: (PREFIX_COPY_IPV4, PREFIX_COPY_IPV6) New macros
	  for better performance than the general prefix_copy function.
	* zclient.c: (zebra_interface_address_read) For non-null destination
	  addresses, set prefixlen to equal the address prefixlen.  This
	  is needed to get the new CONNECTED_PREFIX macro to work properly.
	* connected.c: (connected_up_ipv4, connected_down_ipv4,
	  connected_up_ipv6, connected_down_ipv6) Simplify logic using the
	  new CONNECTED_PREFIX macro.
	  (connected_add_ipv4) Set prefixlen in destination addresses (required
	  by the CONNECTED_PREFIX macro).  Use CONNECTED_PEER macro instead
	  of testing for IFF_POINTOPOINT.  Delete invalid warning message.
	  Warn about cases where the ZEBRA_IFA_PEER is set but no
	  destination address has been supplied (and turn off the flag).
	  (connected_add_ipv6) Add new flags argument so callers may set
	  the ZEBRA_IFA_PEER flag.  If peer/broadcast address satisfies
	  IN6_IS_ADDR_UNSPECIFIED, then reject it with a warning.
	  Set prefixlen in destination address so CONNECTED_PREFIX will work.
	* connected.h: (connected_add_ipv6) Add new flags argument so
	  callers may set the ZEBRA_IFA_PEER flag.
	* interface.c: (connected_dump_vty) Use CONNECTED_PEER macro
	  to decide whether the destination address is a peer or broadcast
	  address (instead of checking IFF_BROADCAST and IFF_POINTOPOINT).
	* if_ioctl.c: (if_getaddrs) Instead of setting a peer address
	  only when the IFF_POINTOPOINT is set, we now accept a peer
	  address whenever it is available and not the same as the local
	  address.  Otherwise (no peer address assigned), we check
	  for a broadcast address (regardless of the IFF_BROADCAST flag).
	  And must now pass a flags value of ZEBRA_IFA_PEER to
	  connected_add_ipv4 when a peer address is assigned.
	  The same new logic is used with the IPv6 code as well (and we
	  pass the new flags argument to connected_add_ipv6).
	  (if_get_addr) Do not bother to check IFF_POINTOPOINT: just
	  issue the SIOCGIFDSTADDR ioctl and see if we get back
	  a peer address not matching the local address (and set
	  the ZEBRA_IFA_PEER in that case).  If there's no peer address,
	  try to grab SIOCGIFBRDADDR regardless of whether IFF_BROADCAST is set.
	* if_ioctl_solaris.c: (if_get_addr) Just try the SIOCGLIFDSTADDR ioctl
	  without bothering to check the IFF_POINTOPOINT flag.  And if
	  no peer address was found, just try the SIOCGLIFBRDADDR ioctl
	  without checking the IFF_BROADCAST flag.  Call connected_add_ipv4
	  and connected_add_ipv6 with appropriate flags.
	* if_proc.c: (ifaddr_proc_ipv6) Must pass new flags argument to
	  connected_add_ipv6.
	* kernel_socket.c: (ifam_read) Must pass new flags argument to
	  connected_add_ipv6.
	* rt_netlink.c: (netlink_interface_addr) Copy logic from iproute2
	  to determine local and possible peer address (so there's no longer
	  a test for IFF_POINTOPOINT).  Set ZEBRA_IFA_PEER flag appropriately.
	  Pass new flags argument to connected_add_ipv6.
	  (netlink_address) Test !CONNECTED_PEER instead of if_is_broadcast
	  to determine whether the connected destination address is a
	  broadcast address.
	* bgp_nexthop.c: (bgp_connected_add, bgp_connected_delete)
	  Simplify logic by using new CONNECTED_PREFIX macro.
	* ospf_interface.c: (ospf_if_is_configured, ospf_if_lookup_by_prefix,
	  ospf_if_lookup_recv_if) Simplify logic using new CONNECTED_PREFIX
	  macro.
	* ospf_lsa.c: (lsa_link_ptop_set) Using the new CONNECTED_PREFIX
	  macro, both options collapse into the same code.
	* ospf_snmp.c: (ospf_snmp_if_update) Simplify logic using new
	  CONNECTED_ID macro.
	  (ospf_snmp_is_if_have_addr) Simplify logic using new CONNECTED_PREFIX
	  macro.
	* ospf_vty.c: (show_ip_ospf_interface_sub) Use new CONNECTED_PEER macro
	  instead of testing the IFF_POINTOPOINT flag.
	* ospfd.c: (ospf_network_match_iface) Use new CONNECTED_PEER macro
	  instead of testing with if_is_pointopoint.  And add commented-out
	  code to implement alternative (in my opinion) more elegant behavior
	  that has no special-case treatment for PtP addresses.
	  (ospf_network_run) Use new CONNECTED_ID macro to simplify logic.
	* rip_interface.c: (rip_interface_multicast_set) Use new CONNECTED_ID
	  macro to simplify logic.
	  (rip_request_interface_send) Fix minor bug: ipv4_broadcast_addr does
	  not give a useful result if prefixlen is 32 (we require a peer
	  address in such cases).
	* ripd.c: (rip_update_interface) Fix same bug as above.
2006-12-12 19:18:21 +00:00
Paul Jakma
27b472533b [zebra] Fix CID #104, check addr for null, and #18, check nexthop type args
2006-07-02 Paul Jakma <paul.jakma@sun.com>

	* rt_netlink.c: (netlink_interface_addr) Fix CID #104, can not
	  proceed if addr is NULL.
	* zebra_rib.c: (static_add_ipv6) Fix CID #18, double check
	  required arguments are supplied for the given nexthop type.
2006-07-02 16:38:54 +00:00
paul
d34b8991b4 [zebra] Record NEWADDR metric on PF_ROUTE, print CACHEINFO debug on netlink
2006-01-17 Paul Jakma <paul.jakma@sun.com>

	* kernel_socket.c: (ifam_read) Read metric from RTM_NEWADDR.
	  If interface is an alias, pass the alias as a label for
	  connected_add_ipv{4,6}.
	* rt_netlink.c: (netlink_interface_addr) print out
	  IFA_CACHEINFO info, if present, when debugging kernel
	  messages.
2006-01-17 18:03:04 +00:00
paul
6621ca868c [zebra] fix some small compile errors, mark several functions static
2005-11-23 Paul Jakma <paul.jakma@sun.com>

	* (general) fix some small compile errors, and mark several
          functions as static.
        * kernel_socket.c: (ifan_read) should be static.
          fix missing brackets.
          (ifm_read,ifam_read,rtm_read_mesg,kernel_read) Make static
          (ifam_read_mesg) make static. fix incorrect variable name.
          (rtm_read) make static. Fix call to rib_delete_ipv4 which
          should be rib_delete_ipv6.
          (routing_socket,kernel_init) should be static. Void argument
          should be specified as such, not left incomplete.
        * rt_netlink.c: rt.h should be included, contains prototypes of
          exported functions.
          (kernel_delete_ipv6_old) fix sign of index argument.
        * rt_socket.c: Exact same as previous. Also, make various
          functions static.
        * rtread_getmsg.c: Include zserv.h, which prototypes
          route_read. Make static.
        * rtread_sysctl.c: zserv.h and rt.h should be included.
          fix definition of route_read.
2005-11-23 13:02:08 +00:00
paul
0752ef0b2e 2005-11-03 Paul Jakma <paul.jakma@sun.com>
* connected.{c,h}: Include memory.h
	  (connected_add_ipv4) Use MTYPE for ifc label.
	  (connected_add_ipv6) Also should accept label. Store it in ifp.
	  (connected_del_ipv4) Taking label as argument is pointless.
	* rt_netlink.c: (netlink_interface_addr) update label usage
	  for connected_{add,delete} functions.
	* if_ioctl.c: (if_getaddrs) NULL label for connected_add_ipv6.
	* if_ioctl_solaris.c: (interface_list_ioctl) Pass LIFC_NOXMIT
	  so we also find out about NOXMIT interfaces like VNI.
	  Bit of hackery to turn interface names into the primary
	  interface name, later with routing socket messages we only
	  will about primary interfaces anyway, so we must normalise
	  the name.
	  (if_get_addr) take label as argument, so it can
	  be passed to connected_add.
	  If label is provided, then it is interface name to issue the
	  ioctl for address information on, not the ifp name.
	  (interface_list) List AF_UNSPEC too, just in case.
	* if_proc.c: (ifaddr_proc_ipv6) label for connected_add_ipv6.
	* interface.c: (if_addr_wakeup) Some very bogus code - sets
	  IFF_RUNNING - add comment.
	  (if_refresh)
	  (ip_address_install) Use MTYPE for ifc label.
	* ioctl_solaris.c: (if_mangle_up) New function. Hackery to make
	  IFF_UP reflect whether any addresses are left on the
	  interface, as we get signalled for IFF_UP flags change on the
	  primary interface only. Logical interfaces dont generate
	  IFINFO, but we do get an RTM_DELADDR.
	  (if_get_flags) Call if_mangle_up before return.
	* kernel_socket.c: (ifam_read) Fixup calls to
	  connected_{add,delete} to match above changes. Rename gate
	  variable to brd, less confusing.
	  Pass the interface name as a label, if it is not same name
	  as ifp->name.
2005-11-03 12:35:21 +00:00
ajs
c05612b9a7 2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* rt_netlink.c: (netlink_request) Use memset to clear structure
	  before calling sendto (eliminates a valgrind error message about
	  uninitialized data).
2005-10-01 16:36:54 +00:00
hasso
be61c4eb59 * zebra_rib.c, rib.h: Add distance and metric arguments to the
rib_add_ipv6() function so that IPv6 routes in RIB can have correct
	  metric. No IPv6 routing daemon uses distance yet though.
	* zserv.c, connected.c, kernel_socket.c, rt_netlink.c,
	  rtread_proc.c,zserv.c: Pass metric and distance info to the
	  rib_add_ipv6().

	Forwardport from stable branch.
2005-08-27 06:05:47 +00:00
hasso
1ada81981d * rt_netlink.c: Remove unused netlink-addr socket declaration.
* rt_netlink.c (netlink_parse_info): Fix debug messages - nlmsg_pid is
	  unsigned and one zlog call had swapped arguments.
	* rt_netlink.c (netlink_route_multipath): Fix compile with disabled
	  IPv6 support.

	[backport candidate] - with stuff commited to rt_netlink.c before to
	fix logging in netlink_route_multipath().
2005-06-12 11:28:18 +00:00
hasso
fa59980fc8 * rt_netlink.c: One tiny missing comma caused pointless debug messages
about IPv6 nexthops.
2005-04-09 16:59:28 +00:00
hasso
206d8055fc * rt_netlink.c (netlink_parse_info): Fix warning. It's safe to cast
status to unsigned here, because we already checked that it isn't
	  negative or 0.
	* rt_netlink.c (netlink_interface_addr): Prefix length belongs to the
	  address, not to the interface.
	* rt_netlink.c (netlink_route_multipath): Fix debug. No useless info
	  is printed out now and IPv6 info is handeled.
2005-04-09 16:38:51 +00:00
ajs
d2fc88962a 2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Fix problems when netlink interfaces are renamed (same ifindex used
	for a new interface).  Start cleaning up some problems with the way
	interface names are handled.
	* interface.c: (if_new_intern_ifindex) Remove obsolete function.
	  (if_delete_update) After distributing the interface deletion message,
	  set ifp->ifindex to IFINDEX_INTERNAL.
	  (if_dump_vty) Detect pseudo interface by checking if ifp->ifindex is
	  IFINDEX_INTERNAL.
	  (zebra_interface) Check return code from interface_cmd.func.
	  Do not set internal ifindex values to if_new_intern_ifindex(),
	  since we now use IFINDEX_INTERNAL for all pseudo interfaces.
	* kernel_socket.c: (ifm_read) Fix code and comments to reflect that
	  all internal interfaces now have ifp->ifindex set to IFINDEX_INTERNAL.
        * rt_netlink.c: (set_ifindex) New function used to update ifp->ifindex.
	  Detects interface rename events by checking if that ifindex is already
	  being used.  If it is, delete the old interface before assigning
	  the ifindex to the new interface.
	  (netlink_interface, netlink_link_change) Call set_ifindex to update
	  the ifindex.
	* if.h: Remove define for IFINDEX_INTERNBASE and add define
	  IFINDEX_INTERNAL 0, since all internal (i.e. non-kernel) pseudo-
	  interfaces should have ifindex set to 0.
	  (if_new) Remove function.
	  (if_delete_retain) New function to delete an interface without
	  removing from iflist and freeing the structure.
	  (ifname2ifindex) New function.
	* if.c: (if_new) Remove function (absorb into if_create).
	  (if_create) Replace function if_new with call to calloc.
	  Set ifp->ifindex to IFINDEX_INTERNAL.  Fix off-by-one error
	  in assert to check length of interface name.  Add error message
	  if interface with this name already exists.
	  (if_delete_retain) New function to delete an interface without
	  removing from iflist and freeing the structure.
	  (if_delete) Implement with help of if_delete_retain.
	  (ifindex2ifname) Reimplement using if_lookup_by_index.
	  (ifname2ifindex) New function to complement ifindex2ifname.
	  (interface) The interface command should check the name length
	  and fail with a warning message if it is too long.
	  (no_interface) Fix spelling in warning message.
	  (if_nametoindex) Reimplement using if_lookup_by_name.
	  (if_indextoname, ifaddr_ipv4_lookup) Reimplement using
	  if_lookup_by_index.
	* bgp_zebra.c: (bgp_interface_delete) After deleting, set ifp->ifindex
	  to IFINDEX_INTERNAL.
	* isis_zebra.c: (isis_zebra_if_del) Call if_delete_retain instead
	  of if_delete, since it is generally not safe to remove interface
	  structures.  After deleting, set ifp->ifindex to IFINDEX_INTERNAL.
	  (zebra_interface_if_lookup) Tighten up code.
	* ospf6_zebra.c: (ospf6_zebra_if_del) Previously, this whole function
	  was commented out.  But this is not safe: we should at least update
	  the ifindex when the interface is deleted.  So the new version
	  updates the interface status and sets ifp->ifindex to
	  IFINDEX_INTERNAL.
	  (ospf6_zebra_route_update) Use if_indextoname properly.
	* ospf_vty.c: (show_ip_ospf_interface_sub) Show ifindex and interface
	  flags to help with debugging.
	* ospf_zebra.c: (ospf_interface_delete) After deleting, set ifp->ifindex
	  to IFINDEX_INTERNAL.
	  (zebra_interface_if_lookup) Make function static.  Tighten up code.
	* rip_interface.c: (rip_interface_delete) After deleting, set
	  ifp->ifindex to IFINDEX_INTERNAL.
	* ripng_interface.c: (ripng_interface_delete) After deleting, set
	  ifp->ifindex to IFINDEX_INTERNAL.
2005-04-02 18:38:43 +00:00
hasso
b7ed1ec7d6 * rt_netlink.c (netlink_talk_filter): Show always warning message,
it's not for debug.
	* rt_netlink.c (netlink_talk): Don't assume we use netlink_cmd
	  although we do now actually.
	* rt_netlink.c (netlink_route, netlink_route_multipath): Always use
	  netlink_cmd to send messages to the kernel.

	[backport candidate]
2005-03-31 20:13:49 +00:00
ajs
a608bbf27b 2005-03-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* rt_netlink.c: (netlink_link_change) If the status of an
	  operative interface changes (e.g. MTU changes), the client
	  daemons should be notified by calling zebra_interface_up_update.
	  Previously, the information was being updated in zebra's
	  interface structure, but the clients were not notified of
	  changes to an operative interface.
	* ospf_zebra.c: (ospf_interface_state_up) If the MTU of an operative
	  interface changes, print a debug message and call ospf_if_reset()
	  to simulate down/up on the interface.
	* ospf_interface.h: Declare new function ospf_if_reset().
	* ospf_interface.c: (ospf_if_reset) New function to call ospf_if_down
	  and ospf_if_up for all ospf interfaces attached to an interface.
2005-03-29 17:03:49 +00:00
paul
c1f01f358d 2005-03-12 Paul Jakma <paul@dishone.st>
* rt_netlink.c: (netlink_route_multipath) dont set equalise flag.
	  No stock Linux kernel has ever supported it, and even if it had
2005-03-12 06:33:14 +00:00
hasso
e8274dcde1 * rt_netlink.c: Don't show messages "ignoring message type 0x001[89]"
if we are not debugging.
2005-02-20 19:09:23 +00:00
paul
1e19315262 2005-02-14 Paul Jakma <paul@dishone.st>
* Not all Linux netlink systems have IFLA_WIRELESS
2005-02-14 23:53:05 +00:00
ajs
4be019d553 2005-01-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* rt_netlink.c: (netlink_socket,netlink_request,netlink_parse_info,
	  netlink_talk) Save errno before calling zserv_privs.change.

	  [backport candidate]
2005-01-29 16:12:41 +00:00
paul
c15cb24241 2005-01-24 Martin Pot <mpot at martybugs.net>
* zebra/rt_netlink.c: ignore wireless newlink netlink messages.
2005-01-24 09:05:27 +00:00
ajs
b617800227 2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* *.c: Change level of debug messages to LOG_DEBUG.
2004-12-07 21:12:56 +00:00
ajs
6099b3b569 2004-11-19 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* global: Replace strerror with safe_strerror.  And vtysh/vtysh.c
	  needs to include "log.h" to pick up the declaration.
2004-11-20 02:06:59 +00:00
hasso
3fb9cd6ef4 OK. Here it is - PtP patch from Andrew J. Schorr. No problems with ospfd,
ripd might need some more testing though.
2004-10-19 19:44:43 +00:00
hasso
fce954f8de Fix warnings. Didn't even look at files not compiled in Linux though. 2004-10-07 20:29:24 +00:00
hasso
c9e52be3f4 Compiler warnings fixes. 2004-09-26 16:09:34 +00:00
hasso
c34b6b577e Commit my hack (yes, I still call it hack) - command line switch for zebra
daemon to change netlink receive buffer size.
2004-08-31 13:41:49 +00:00
hasso
55e7ecd114 Remove pointless privilege lower call. Thanks to Cougar for noticing. 2004-08-06 08:41:56 +00:00
paul
44145db3ae 2004-05-09 Paul Jakma <paul@dishone.st>
* ioctl.c: (if_get_mtu) set mtu6 to mtu
	* mtu_kvm.c: (if_kvm_get_mtu) set mtu6 to mtu
	* rt_netlink.c: (netlink_interface) set mtu6 to mtu
	  (netlink_link_change) ditto

2004-05-09 Sowmini Varadhan <sowmini.varadhan@sun.com>

	* interface.c: (if_delete_update) only used with HAVE_NETLINK
	  and RTM_IFANNOUNCE.
	  (if_flag_dump_vty) Solaris IFF_IPV4 and IFF_IPV6 if flags
	  (if_dump_vty) print mtu6 if not same as mtu
2004-05-09 11:00:23 +00:00
hasso
34195bf6dd [quagga-dev 1002]. Also fix date of previous commit in Chanelog. 2004-04-06 12:07:06 +00:00
hasso
5707ccee87 Fix warning. Approved by Amir. 2004-03-04 19:20:44 +00:00
paul
b84d3a1b6e 2003-11-17 Jay Fenlason <fenlason@redhat.com>
* zebra/rt_netlink.c: netlink_parse_info() ignore messages which are
	  not from kernel. Reported to RH by Herbert Xu. See
	  http://rhn.redhat.com/errata/RHSA-2003-307.html and CAN-2003-0858.
2003-11-17 10:31:01 +00:00
paul
31a476c7e9 2003-09-29 Paul Jakma <paul@dishone.st>
* zebra/connected.c: revert the 'generic PtP' patch as it causes
	far too many problems. People who use FreeSWAN should investigate
	native linux ipsec.
	* zebra/rt_netlink.c: ditto
	* lib/if.c: ditto
	* ripd/ripd.h: ditto
	* ripd/ripd.c: ditto
	* ripd/rip_interface.c: ditto
	* ospfd/ospfd.c: ditto
	* ospfd/ospf_snmp.c: ditto
	* bgpd/bgp_nexthop.c: ditto
2003-09-29 19:54:53 +00:00
paul
7021c425a9 2003-07-15 Paul Jakma <paul@dishone.st>
* lib/version.h: add ZEBRA_URL (unused for now)
        * lib/vty.c: CMD_ERR_NOTHING_TODO when reading conf file should not
          be fatal. slight reformating.
        * ospfd/ospf_zebra.c: ignore reject/blackhole routes if zebra sends
          these type of routes. probably should be a new type of route to
          allow daemons to more easily choose whether to redistribute them
          - rathen than just a flag (eg for reject/blackhole).
          reorder the is_prefix_default test for ZEBRA_IPV4_ROUTE_DELETE to
          avoid the inverted test - slightly more readable.
        * redhat/zebra.spec.in: Add ospfapi port to services file, if
          with_ospfapi.
        * zebra/rib.h: Change nexthop types to an enum.
        * zebra/rt_netlink.c: run it through indent -nut.
          Add nexthop_types_desc[] descriptive array for nexthop types.
          (netlink_route_multipath) debug statements indicate which branch
          they are in and print out nexthop type.
        * zebra/zebra_rib.c: slight reformatting.
        * zebra/zebra_vty.c: Pass ZEBRA_FLAG_BLACKHOLE flag to
          static_add_ipv4() if Null0 route is configured. print out Null0 if
          STATIC_IPV4_BLACKHOLE route, and ignore flags (shouldnt be
          possible to set flags from vty) for config and show route.
2003-07-15 12:52:22 +00:00
paul
5ec90d28c9 2003-06-19 Vladimir Ivaschenko <hazard@francoudi.com>
* zebra/rt_netlink.c: Debug statements added to
          netlink_route_multipath()
	* zebra/zebra_rib.c: If route has a gateway, delete only existing
          route with that specified gateway.
2003-06-19 01:41:37 +00:00
paul
b21b19c578 2003-06-15 Paul Jakma <paul@dishone.st>
* lib/vty.{c,h}: Remove vty layer depending on a 'master' global,
	  pass the thread master in explicitly to vty_init. Sort out some
	  header dependency problems with lib/command.h
	* zebra/: Move globals to struct zebrad. Update vty_init().
	* (.*)/\1_main.c: update call to vty_init().
2003-06-15 01:28:29 +00:00
paul
edd7c245d3 2003-06-04 Paul Jakma <paul@dishone.st>
* Merge of zebra privileges
2003-06-04 13:59:38 +00:00
paul
595db7f165 Add back support for null0 interface blackhole routes. 2003-05-25 21:35:06 +00:00
hasso
81dfcaa2e2 Route (reject|blackhole) support from 6Wind patch. 2003-05-25 19:21:25 +00:00
paul
5f37d86f83 From: Israel Keys <ikeys@agile.tv>
Subject: [zebra 18677] zebra initialisation bug and patch

Hi All,

I have found a bug in zebra that prevents its routing table and
interface database from being initialised properly. The problem occurs
when a request is made via the netlink socket but the kernel produces a
EWOULDBLOCK/EAGAIN when the result is trying to be retrieved via a
recvmsg(). Zebra does not do anything about this and continues to
function  (with an empty routing table and interface list) as if nothing
has happened. With no such information the routing protocol dosn't work!

Two functions are called during the initialisation of Zebra:
interface_lookup_netlink() and netlink_route_read() - obtaining the
interfaces and routing table from the kernel respectively. These are the
only time these functions are called.

These functions, interface_lookup_netlink() and netlink_route_read(),
use netlink_parse_info() to recieve the data from the netlink socket.
The problem is, netlink_parse_info() returns (without error) when its
call to recvmsg() results in an errno EWOULDBLOCK/EAGAIN. This behaviour
is expected by other funtions calling netlink_parse_info() -
netlink_parse_info is simply recalled at a later stage. However, on
initialisation it is never recalled.

Since zebra is expected to nothing else during initialisation it was
easiest to temporarily change the netlink socket to BLOCK and wait
indefinently until the kernel responds with the required information.

Attached is a patch with these changes.

Comments and questions are welcome.
Please inform me if this patch is added to the Zebra source.

--israel
2003-04-19 00:11:28 +00:00
paul
13766da4e4 Sync to latest Zebra CVS 2003-02-07 14:46:23 +00:00
paul
d753e9eec9 Matthew Grant <grantma@anathoth.gen.nz>
Subject: [zebra 17290] [PATCHES] - Fixes for problems in 0.93b

Added ifupstaticfix
2003-01-22 19:45:50 +00:00
paul
8fdcfdecd5 Add work around for RFC3021 patch and its problem with certain IPv6 interfaces
addresses.

It seems so far that netlink only ever returns IFA_ADDRESS for IPv6 interfaces
and never IFA_LOCAL, regardless of whether it is PtP or not. Need to investigate
precisely how IPv6 and netlink are supposed to behave wrt broadcast vs
PtP links.
2003-01-19 20:52:55 +00:00
paul
e04ab74d17 From havanna_moon@gmx.net Fri Jan 17 23:37:49 2003
Date: Sat, 11 Jan 2003 23:26:28 +0100 (CET)
From: Yon Uriarte <havanna_moon@gmx.net>
To: "the list(tm) Zebra" <zebra@zebra.org>
Subject: [zebra 17217] [PATCH] show thread CPU

Hi,

 a little patch from the 'stupid preprocessor tricks' collection to record
thread statistics.

Usage: "show thread cpu [r][w][t][e][x]"

Output Fields: self explaining I hope. Type is one of RWTEX for:
   Read, Write (fd threads), Timer, Event, Execute.

 Overhead vs. vanilla zebra: almost nothing. Vanilla CVS zebra already
collects thread run times.


 Caveats: Under linux getrusage has a granularity of 10ms, which is almost
useless in this case. Run ./configure, edit config.h and comment out
"#define HAVE_RUSAGE",  this way it will use getimeofday which has a much
better granularity. IMHO this is better, as cooperative threads are
effectively running during all that wall time (dont care if CPU
utilization was 3% or 99% during the time the thread was running (an
effective rusage combined with getimeofday could give that info)).

 Maybe someone can give tips for other platforms on API granularity.


TODO: change some of the calls to thread_add_$KIND to
funcname_thread_add_$KIND with a meaningfull funcname, so users will get a
better idea of what's going on.

F.ex. (AFAIK):
ospf_spf_calculate_timer -> "Routes Step 1, areas SPF"
ospf_ase_calculate_timer -> "Routes Step 2, externals"



 Could this be added to the unofficial patch collection?

Could someone with BGP keepalive problems run their bgpd with this patch
and post the results?


TIA, HTH, HAND, regards
 yon


Example output:
--------------------------------
ospfd# show thread cpu
 Runtime(ms)    Invoked Avg uSecs   Max uSecs  Type Thread
      14.829         31       478         585   T   ospf_ase_calculate_timer
      82.132       9838         8         291    EX ospf_nsm_event
       0.029          1        29          29    E  ospf_default_originate_timer
       0.254          9        28          34   T   ospf_db_desc_timer
       0.026          7         3          11   T   ospf_wait_timer
     669.015        523      1279      490696 R     vty_read
       4.415         45        98         173   TE  ospf_network_lsa_refresh_timer
      15.026         31       484         588   T   ospf_spf_calculate_timer
      29.478       1593        18         122    E  ospf_ls_upd_send_queue_event
       0.173          1       173         173   T   vty_timeout
       4.173        242        17          58    E  ospf_ls_ack_send_event
     637.767     121223         5          55   T   ospf_ls_ack_timer
      39.373        244       161        2691 R     zclient_read
      12.169         98       124         726    EX ospf_ism_event
       0.226          2       113         125 R     vty_accept
     537.776      14256        37        3813  W    ospf_write
       4.967         41       121         250   T   ospf_router_lsa_timer
       0.672          1       672         672    E  zclient_connect
       7.901       1658         4          26   T   ospf_ls_req_timer
       0.459          2       229         266    E  ospf_external_lsa_originate_timer
       3.203         60        53         305   T   ospf_maxage_lsa_remover
     108.341       9772        11          65   T   ospf_ls_upd_timer
      33.302        525        63        8628  W    vty_flush
       0.101          1       101         101   T   ospf_router_lsa_update_timer
       0.016          1        16          16   T   ospf_router_id_update_timer
      26.970        407        66         176   T   ospf_lsa_maxage_walker
     381.949      12244        31          69   T   ospf_hello_timer
       0.114         22         5          14   T   ospf_inactivity_timer
      34.290       1223        28         310   T   ospf_lsa_refresh_walker
     470.645       6592        71         665 R     ospf_read
    3119.791     180693        17      490696 RWTEX TOTAL
ospfd#

bgpd# sh t c TeX
 Runtime(ms)    Invoked Avg uSecs   Max uSecs  Type Thread
      21.504        476        45          71   T   bgp_keepalive_timer
      17.784       1157        15         131   T   bgp_reuse_timer
      29.080        193       150         249   T   bgp_scan
      23.606        995        23         420    E  bgp_event
     317.734      28572        11          69   T   bgp_routeadv_timer
       0.084          1        84          84    E  zlookup_connect
       0.526          1       526         526    E  zclient_connect
       1.348         13       103         147   T   bgp_start_timer
      19.443        142       136         420   T   bgp_connect_timer
      16.032        772        20          27   T   bgp_import
     447.141      32322        13         526   TEX TOTAL
bgpd#
bgpd# show thread cpu rw
 Runtime(ms)    Invoked Avg uSecs   Max uSecs  Type Thread
     155.043          7     22149      150659 R     bgp_accept
     129.638        180       720       53844 R     vty_read
       1.734         56        30         129 R     zclient_read
       0.255          2       127         148 R     vty_accept
      58.483        983        59         340 R     bgp_read
     171.495      29190         5         245  W    bgp_write
      13.884        181        76        2542  W    vty_flush
     530.532      30599        17      150659 RW    TOTAL
bgpd#
--------------------------------
2003-01-17 23:47:00 +00:00
paul
00df0c1e80 [zebra 14631] Generic PtP and RFC3021 interface addressing support 2002-12-13 21:07:36 +00:00
paul
2e3b2e474e zebra link state detection support 2002-12-13 21:03:13 +00:00
paul
718e374419 Initial revision 2002-12-13 20:15:29 +00:00