Commit Graph

122 Commits

Author SHA1 Message Date
Don Slice
fec4ca191e zebra: if multiple connecteds, select loopback or vrf if present
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-23 18:49:48 +00:00
Quentin Young
af4c27286d *: rename zlog_fer -> flog_err
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Donald Sharp
d9ff430273 pimd: Add pim_errors and define some pim specific errors
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
paco
a2b6e694b1
bgpd isisd ldpd lib ospfd pimd: redundancy (infer)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-20 22:25:28 +02:00
Donald Sharp
7f432a28e0 pimd: Cleanup pim_if_is_loopback
The interface itself knows if it is a vrf device or
not, so let's just use a check for that in the decision
if a interface is a loopback or not.

Additionally modify function to return a bool.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-30 07:53:01 -04:00
Donald Sharp
05d8470ff5 pimd: Fix crash when looking up incoming interface
It is possible that the incoming interface lookup
will fail because we are in transition from one vrf
to another.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:39 -04:00
Donald Sharp
2aa1ca8418 pimd: When we are initializing a pim socket limit hellos
When we are initializing a pim socket for vrf or loopback
interfaces do not schedule a hello to go out at all.

I'm currently leaving the check on is a vrf / loopback
device on the actual send as that we have several paths
to get there.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:39 -04:00
Donald Sharp
a5b6bd2be3 pimd: Ensure packet received on vrf interface is configured for pim
In a vrf configuration, when we receive a pim packet we lookup
the correct incoming interface.  There exists a chance that
the correct incoming interface has not been configured to use
pim yet.  gracefully bow out and do nothing with the packet.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:39 -04:00
Donald Sharp
9487552c1c pimd: Reschedule the correct interface for incoming packets
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:38 -04:00
Donald Sharp
e2d451e2ee pimd: Trust the recvfromto ifindex information
The vrf interface is receiving the pim packet
instead of the slave interface that is bound.

Lookup the ifindex ifp pointer from that.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:38 -04:00
Donald Sharp
11699c4788 pimd: Don't send hello's out vrf interface
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:38 -04:00
Donald Sharp
ef434d3e39 pimd: Cleanup pim_pim use of pimg
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:37 -04:00
Donald Sharp
b206566b16 pimd: Remove pimg from pim_register.c
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:36 -04:00
Donald Sharp
0708beb1f4 pimd: Cleanup use of VRF_DEFAULT to pimg->vrf_id
Use the appropriate vrf_id instead of always defaulting
to VRF_DEFAULT

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:33 -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
4a07939b68 pimd: Thread changes allow pim to crash a boo
When we add a thread pointer to thread_add_XXX functions
when the specified function is called, thread.c is setting
the thread pointer to NULL.  This was causing pim to
liberally pull it's zassert grenade pin's.

Additionally clean up code to not set the NULL pointer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-17 20:33:43 -04: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
Quentin Young
ffa2c8986d *: remove THREAD_ON macros, add nullity check
The way thread.c is written, a caller who wishes to be able to cancel a
thread or avoid scheduling it twice must keep a reference to the thread.
Typically this is done with a long lived pointer whose value is checked
for null in order to know if the thread is currently scheduled.  The
check-and-schedule idiom is so common that several wrapper macros in
thread.h existed solely to provide it.

This patch removes those macros and adds a new parameter to all
thread_add_* functions which is a pointer to the struct thread * to
store the result of a scheduling call. If the value passed is non-null,
the thread will only be scheduled if the value is null. This helps with
consistency.

A Coccinelle spatch has been used to transform code of the form:

  if (t == NULL)
    t = thread_add_* (...)

to the form

  thread_add_* (..., &t)

The THREAD_ON macros have also been transformed to the underlying
thread.c calls.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-09 20:44:19 +00:00
Donald Sharp
096398104b Merge branch 'master' into pim_5549 2017-04-05 12:49:17 -04:00
Donald Sharp
e43223bcc3 pimd: Cleanup unused variable write
There exists a common pattern in pim where we were setting
a variable to a value in the error case when we would no
longer need it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-31 16:28:22 -04:00
Donald Sharp
dba7860904 pimd: Send v6 secondary addresses to neighbors in hello
Send v6 secondary addresses to our neighbor in hello's.

Additionally allow the disabling it via the cli introduced
earlier.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-30 09:34:03 -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
Donald Sharp
4961e0ad8f pimd: Trust the compiler
When we set a variable to NULL, there is no
need to assert on it the following line.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-24 10:03:41 -05:00
Donald Sharp
b50fcf3aa8 pimd: Remove unnecessary ip header length checks on receipt.
The kernel will not hand us a malformed packet.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-24 10:03:40 -05:00
Donald Sharp
910dad7e99 pimd: Remove unnecessary check in packet process path
When we get a packet from the network for pim, we do not
need to check to see that it is a pim packet, since that
is what we've asked to receive.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-24 10:03:40 -05:00
Donald Sharp
f8e7d7992f pimd: Assume buffer size passed in is of sufficient size
For:
pim_msg_build_header
pim_msg_addr_encode_ipv4_ucast
pim_msg_addr_encode_ipv4_group
pim_msg_addr_encode_ipv4_source

Assume that the buffer size passed in is of sufficient size
already.  This is assured already because buffer sizes
are checked for minimum lengths for the entire packet
ahead of time.  So we are double checking.

Additionally at scale we will be calling these functions
a very very large number of times.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-24 10:03:40 -05:00
Donald Sharp
70ce34ae66 pimd: Add 'struct pim_msg_header' packed data structure.
Add the 'struct pim_msg_header' and convert
all places that encoded/decoded the message header
to use it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-24 10:03:40 -05:00
Donald Sharp
05ea5ceecf pimd: Allow IPDEFTTL to be used for omnios
The omnios OS has no IPDEFTTL defined.
Add the ability to handle it for this
one case.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-14 16:19:16 -05:00
Chirag Shah
d62c5c0381 pimd: messages to neighbors should have TTL = 1
Ticket:CM-12924
Reviewed By:shapd
Testing Done: configure PIM neighbor, verify PIM hello packet dump for ttl to be 1.

Set TTL to 1 for outgoing multicast control packets destine to ALL-PIM-ROUTERS as oppose to unicast mcast packets.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-02-14 15:52:56 -05:00
Chirag Shah
5637da0501 pimd: non-null register checksum incorrect
Ticket: CM-12041
Reviewed By: sharpd, CCR-5556
Testing Done: Tested on Local setup generating PIM Register (Data/Null) and processing both Tx/Rx with correct checksum.
Provided quagga debian to submitter and checksum cases passed on submitter setup.

1. PIM Register msg checksum only accounts for 8 bytes (4 bytes for PIM header and next 4 byetes before data payload).
In PIM header checksum calculation checked PIM packet type (in this case REGISTER type) then only pass 8 bytes as length
rather than full packet length.
2. PIM Register Rx path also handled with 8 byte and full pim lenth checksum.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-02-14 15:52:09 -05:00
Donald Sharp
e5dfe68784 pimd: Refactor pim_sock_open to just need the ifp pointer
In all cases pim_sock_open was called, we just passed
in the pim_ifp->primary_address, which is accessible
from the interface pointer.  So just pass that in.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-03 12:37:39 -05:00
Donald Sharp
b35702d0b8 pimd: Allow a interface in a vrf to be configured.
This fixes the issue a crash when we have configured an interface
inside of a vrf, and apply pim commands to it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-03 12:33:37 -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
5a515ebed0 pimd: Reset neighbor hold time when we receive packet
When we receive a packet from a neighbor, reset the
hold time as that we *know* that they are still
alive.

During heavy packet load, we were seeing cases
where neighbors were being reset because we
were timing out due to not processing the hello
packet in time.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:18 -05:00
Donald Sharp
67f771b3a3 pimd: Add guard for pim_msg_send_frame
In certain error conditions it is possible to
attempt to send packets when the socket is not ready
instead of dumping to the log a million error messages
only note the issue if we have packet debugs on.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:18 -05:00
Donald Sharp
cf3cd99f5d pimd: Lower Hello sent to be immediate
There exists situations where an interface flaps
and routing recovers and we attempt to install
an upstream but since we have no neighbor out
that interface still.  Let's cause the hello
to go out immediately for the 3.1 release
to allow mrouting to recover in this situation.

We will need to revisit this issue after
we have proper nexthop tracking in place

Ticket: CM-13185
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2016-12-21 20:26:17 -05:00
Donald Sharp
8e4c9ef376 pimd: Add knob to control # of packets read in at one time
Add 'ip pim packets <1-100>' command.

Allows you to control the number of packets read in before
giving control back to another part of the process.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:16 -05:00
Donald Sharp
db48bcb23e pimd: Modify pim_sock_read to read 3 times before yielding
Modify pim_sock_read to read up to 3 packets before yielding
the cpu to something else.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:16 -05:00
Donald Sharp
0f055c0d5d pimd: Further refine debugs in pim_sock_read path
When we received a packet we were dumping packet information
with debugs on 2 times for each packet where we had overlapping
data being passed.

Since debugs are expensive, reduce the count to 1.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:16 -05:00
Donald Sharp
9d8b5695fe pimd: Cleanup handling of pim_sock_read
Cleanup some turned on debug code that is no longer
needed to be turned on in the pim_sock_read
code path.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:16 -05:00
Donald Sharp
def1e80732 pimd: Protect log messages with debug in pim_pim.c
Protect the log messages in pim_pim.c with PIM_DEBUG_PIM_PACKETS

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:15 -05:00
Donald Sharp
7f8b8a9af6 pimd: Remove unnecessary asserts
When we handle the thread arguments,
there is no need to assert.  As that
if they are wrong, we are going down
shortly anyways.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:14 -05:00
Daniel Walton
eaa54bdb67 pimd: replace grp_str[100] with grp_str[INET_ADDRSTRLEN]
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-12-21 20:26:11 -05:00
Donald Sharp
19e550954b pimd: Allow bigger packet sizes when receiving callbacks.
When receiving callbacks from the kernel allow bigger
packet sizes than 3k to be handled appropriately.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:11 -05:00
Donald Sharp
29444f8fee pimd: Fix high cpu load of pim when interface goes down
When a interface goes down we accidently put ourselves into
an infinite loop.

Ticket: CM-12803
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:09 -05:00
Donald Sharp
c305ed63eb pimd: Allow breaking up of packet.
When a packet is too large to send in one go, break it up.

Ticket: CM-12768
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:08 -05:00
Donald Sharp
6abb1fc25f pimd: Fix double close of socket.
When a interface bounces fix the double close from happening

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:07 -05:00
Donald Sharp
4df01a4e66 pimd: Fix pim to use correct src address for packets
When sending register packets to the RP from the FHR
we should be using the ip address of the incoming interface
that received the mcast packet.

Ticket: CM-12445
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:07 -05:00
Donald Sharp
7e0cff2f98 pimd: Remove unnecessary QuaggaId
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:03 -05:00
Donald Sharp
7f0c1c5fdd pimd: change string to JOINPRUNE
Change the JP message string to JOINPRUNE.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:02 -05:00
Donald Sharp
7643f0a1c6 pimd: Refactor pim message type to an enum
Change the pim message type to an enum and add the ability
to output a string based upon message type.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:02 -05:00
Donald Sharp
566387390f pimd: First Schwag at pim_register_stop
Implement the pim_register_stop state machine.  There are still a few
bugs still but this is enough to get us rolling a bit more.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:02 -05:00
Donald Sharp
59ba0ac3e6 pimd: Fix use of 0 for NULL
pimd uses allot of 0's to represent NULL.  Not a good
programming practice.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:02 -05:00
Donald Sharp
4dffc8807e pimd: Refactor pim message receive
We were using a variety of techniques to handle
incoming pim packets.  Refactor to use a switch
statement to handle the incoming packets.

Also add the ability to notice that we are getting
a register stop.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:02 -05:00
Donald Sharp
3d7765d741 pimd: Fixup some dead code
Remove some dead code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:01 -05:00
David Lamparter
8ef0791cb6 build: remove $Format tags
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-20 17:54:03 +01: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
a22e470b39 pimd: Make received packet zlog_err a zlog_debug
When receiving packets and the parse fails
a zlog_err is generated.  This should be
protected by a debug.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-06-29 07:44:42 -04:00
Donald Sharp
61ea3951a2 pimd: Bind pim sockets to interface they are associated with
When pim is receiving packets, each interface's fd is receiving
packets for all interfaces.  Modify the code to bind the
pim interface sockets to the interface they were created for.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-06-28 21:50:49 -04:00
Donald Sharp
85b62aeab3 pimd: Prevent loopback from forming neighbor
This code prevents pim from forming a neighbor relationship
with itself by preventing pim from sending a hello
out the loopback interface if we have pim configured
on an interface.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-06-17 21:25:21 -04:00
Donald Sharp
744d91b3c6 pimd: Separate pim vif index spot from ifindex
Allow pim to separate out the pim vif index from the ifindex.
This change will allow pim to work with up to 255(MAXVIFS)
interfaces, while also allowing the interface ifindex to
be whatever number it needs to be.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-06-17 20:43:21 -04:00
Donald Sharp
3010e99a56 pim 2016-06-17 10:38:45 -04:00
Donald Sharp
e4cc018527 pimd: Fix of using uninitialized Memory
Valgrind is reporting that pimd is using uninitialized
memory for comparisons.  This commit addresses
the issues found there.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-06-09 15:16:14 -04:00
Donald Sharp
77e390e59e pimd: Start handling of pim REGISTER packet type
This code starts the handling of the pim register type.  No guarantees that
it works correctly, just that it compiles and the start of the code is in there.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-25 20:38:34 -04:00
Donald Sharp
aea6cb942f pimd: Limit pim hello log messages
pimd was outputting allot of data surrounding pim hello packets.
In addition the debugging was inconsistent and not all turned
on via 'debug pim packet hello'.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-25 20:38:33 -04:00
Donald Sharp
566b83cf72 pimd: Notice when we receive a packet type we can't handle yet
There are PIM packet types that have not been implemented yet.
Notice when we get one of those and safely do nothing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-25 20:38:33 -04:00
Donald Sharp
2cd32c6114 pimd: Fix leaked fd
When caling pim_sock_open if the failure cause happens, however
unlikely, don't leak the fd on failure.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-25 20:38:33 -04:00
Donald Sharp
c29c0f61de pimd: Ensure new generation_id is different from previous
The RFC states that an interfaces generation_id must be changed
if it experiences an if down.  From 4.3.1:

The GenID option contains a randomly generated
32-bit value that is regenerated each time PIM forwarding is started
or restarted on the interface, including when the router itself
restarts.

Since we are only grabbing a new generation_id without comparing
it to the previous generation_id, it is possible that random
can generate the exact same number.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-25 20:38:33 -04:00
Donald Sharp
f6f9c0094a pimd: Stop DR election on every hello
The DR election is occurring on every hello received.
This is because the hello receive packet returns a 0
for any successfully received packet.  PIMD then looked
at the 0 returned and did a DR election.

Code was inspected for the cases where DR should happen:
(A) Interface ip address change
(B) DR priority in hello packet changes
(C) Received a new neighbor on an interface
(D) Neighbor timer pops.

Each of these initiate a DR election in the code currently.

Testing was initiated on a pim network:
tor-11# show ip pim designated-router
NonPri: Number of neighbors missing DR Priority hello option

Interface Address         DR              Uptime   Elections Changes NonPri
br1       20.0.15.1       20.0.15.1       00:08:16         1       1      0
swp1      169.254.0.10    169.254.0.10    00:08:16         2       1      0
swp2      169.254.0.26    169.254.0.26    00:08:16         2       1      0
tor-11#

As you can see Elections == 2.  This is because pimd performs
an election on (A) and (C) above.  I see no need to modify
(A) to check if we have any knowledge of the interface before
this call.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-25 20:38:33 -04:00
Donald Sharp
60b40924ea PIMD: Fix code to use srandom/random
pimd rolled it's own solution to random #'s, that was not
terribly random.  Rely on the underlying system to generate
random #'s for us

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-25 20:38:32 -04:00
David Lamparter
59e96cda41 pimd: cast to sockaddr_in to sockaddr
While glibc seems to have something in the system headers that prevents
this from triggering a warning, FreeBSD doesn't.  Fix the warning.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:32 -04:00
David Lamparter
12e41d03bd pimd: merge pimd as of 2015-01-19
Welcome pimd to the Quagga daemon zoo!

This is a merge of commit 77ae369 ("pimd: Log ifindex found for an
interface when zebra lib reports a new connected address."), with
the intermediate "reconnect" changes removed (c9adf00...d274381).
d274381 is replaced with b162ab7, which includes some changes.  In
addition, 4 reconnect-related changes and 1 cosmetic one have been
bumped out.

The rebase command used to produce the branch that is merged here is:
  git rebase --onto b162ab7 c9adf00 77ae369

Note that 3 patches had their author rewritten from
    "Anonymous SR#108542 <>" (which is not a valid git author ID)
to: "Savannah SR#108542 <nbahr@atcorp.com>" (which is the e-mail address
                               listed in the associated Savannah ticket)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:32 -04:00