Commit Graph

104 Commits

Author SHA1 Message Date
Donatas Abraitis
f2058cb425 pimd: Add IGMP join sent/failed statistics
```
exit1-debian-11# sh ip igmp statistics
IGMP statistics
Interface           : global
V1 query            : 0
V2 query            : 0
V3 query            : 0
V2 leave            : 0
V1 report           : 0
V2 report           : 0
V3 report           : 16
mtrace response     : 0
mtrace request      : 0
unsupported         : 0
joins failed        : 0
joins sent          : 11
total groups        : 4
total source groups : 0
exit1-debian-11# sh ip igmp statistics json
{
  "global":{
    "name":"global",
    "queryV1":0,
    "queryV2":0,
    "queryV3":0,
    "leaveV3":0,
    "reportV1":0,
    "reportV2":0,
    "reportV3":16,
    "mtraceResponse":0,
    "mtraceRequest":0,
    "unsupported":0,
    "totalGroups":4,
    "totalSourceGroups":0,
    "joinsFailed":0,
    "joinsSent":11
  }
}
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-13 19:31:34 +02:00
Balaji Gurudoss
023d3e4af8 pim6d: pim6d socket changes
socket changes to support IPv6 PIM

Signed-off-by: Balaji Gurudoss <G_Balaji1@dell.com>
[DL: cleaned up & refactored a whole bunch more.]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-12 15:59:01 +01:00
Donald Sharp
cc9f21da22 *: Change thread->func to return void instead of int
The int return value is never used.  Modify the code
base to just return a void instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23 19:56:04 -05:00
David Lamparter
29fd9fca45 pim6d: IPv6-adjust pim_msg_send() and related
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-02-14 06:45:03 +01:00
Mobashshera Rasool
12e7634018 pimd: Modifying in_addr to pim_addr in struct pim_interface for IPv6
Based on compiler option, pim_addr will be changed to in_addr
or in6_addr for pimd and pim6d respectively.
Reviewed-by: Sarita Patra <saritap@vmware.com>
Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-01-10 21:10:29 -08:00
Donald Sharp
d047ba78d2
Merge pull request #9708 from mobash-rasool/new_b
pimd: hello sent stats counter change and new flag addition to decide hello send
2021-12-02 04:05:03 -05:00
Igor Ryzhov
608c887069 *: unify if_is_loopback/if_is_loopback_or_vrf
We should always treat the VRF interface as a loopback. Currently, this
is not the case, because in some old pre-VRF code we use if_is_loopback
instead of if_is_loopback_or_vrf. To avoid any future problems, the
proposal is to rename if_is_loopback_or_vrf to if_is_loopback and use it
everywhere. if_is_loopback is renamed to if_is_loopback_exact in case
it's ever needed, but currently it's not used anywhere.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-16 18:07:11 +03:00
Donatas Abraitis
bf5335cf34 pimd: Do not explicitly set the thread pointer to NULL
FRR should only ever use the appropriate THREAD_ON/THREAD_OFF
semantics.  This is espacially true for the functions we
end up calling the thread for.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-04 19:29:06 +03:00
Mobashshera Rasool
79992e8a42 pimd: Add a flag to decide PIM has to send Hello
Problem Statement:
==================
pim maintains two counters hello tx and hello rx at interface level.
At present pim needs to send the hello message prior to other pim
message as per RFC. This logic is getting derived from the tx hello
counters. So when a new neighbor is added, tx counters are set to
zero and then based on this, it is further decided to send hello in
pim_hello_require function.

Fix:
====
Separating the hello statistics and the logic to decide when to send hello
based on a new flag. pim_ifstat_hello_sent will be used to note down
the hello stats while a new flag is added to decide whether to send hello
or not if it is the first packet to a neighbor.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-10-03 22:04:34 -07:00
Sai Gomathi
50975049f3 pimd: Fixing coverity issues
Problem
======
In pim_msg_send_frame api, the while loop was executed only once.

Fix
===
while is changed to if, as in the code flow
the while part is getting executed only once.

Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2021-08-24 10:40:03 -07:00
Sai Gomathi
9a15529cda pimd: Fixing coverity issues
Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2021-08-24 10:36:45 -07:00
Donald Sharp
d3cc1e4518 pimd: Remove pim->vrf_id and use pim->vrf->vrf_id
VRF creation can happen from either cli or from
knowledged about the vrf learned from zebra.
In the case where we learn about the vrf from
the cli, the vrf id is UNKNOWN.  Upon actual
creation of the vrf, lib/vrf.c touches up the vrf_id
and calls pim_vrf_enable to turn it on properly.
At this point in time we have a pim->vrf_id of
UNKNOWN and the vrf->vrf_id of the right value.

There is no point in duplicating this data.  So just
remove all pim->vrf_id and use the vrf->vrf_id instead
since we keep a copy of the pim->vrf pointer.

This will remove some crashes where we expect the
pim->vrf_id to be usable and it's not.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-12 14:36:59 -04:00
David Lamparter
df5dfb77b5 pimd: zassert => assert
No point in having pimd use zassert() while everything else uses plain
assert().

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-23 12:25:47 +02:00
Donatas Abraitis
7c98d487b8 *: Replace typo (supress => suppress)
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-11-17 12:13:38 +02:00
Donald Sharp
88b5958e31
Merge pull request #6054 from sarav511/dr2ndr
pimd: When DR becomes non DR, Still sends register packets to RP
2020-06-01 07:58:32 -04:00
Rafael Zalamena
5920b3eb38 *: replace all random() calls
Replace all `random()` calls with a function called `frr_weak_random()`
and make it clear that it is only supposed to be used for weak random
applications.

Use the annotation described by the Coverity Scan documentation to
ignore `random()` call warnings.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-17 20:57:43 -03:00
Russ White
e89bb41d80
Merge pull request #6047 from sarav511/hold0
pimd: Pim hello should be sent with 0 hold time on address change onold src ip
2020-03-24 10:19:17 -04:00
saravanank
23a2f90a00 pimd: Add check for pim join, hello and assert to drop pkts without all-pim-routers dest.
This is as per RFC. This is identified when conformance suite catched join.

RCA:
Packets were processed without checking allowed dest IP for that packet.

Fix:
Added check for dest IP
Converted this check to a function

Signed-off-by: Saravanan K <saravanank@vmware.com>
2020-03-23 05:35:55 -07:00
saravanank
46a9ea8bfa pimd: When DR becomes non DR, couldreg state events not handled.
RCA: Upstreams which are in register state other than noinfo, doesnt remove
register tunnel from oif after it becomes nonDR

Fix: scan upstreams with iif as the old dr and check if couldReg becomes false.
If couldreg becomes false from true, remove regiface and stop reg timer.
Do not disturb the entry. Later the entry shall be removed by kat expiry.

Signed-off-by: Saravanan K <saravanank@vmware.com>
2020-03-19 18:27:37 -07:00
saravanank
b279f95c70 pimd: Pim hello should be sent with 0 hold time on address change on old src ip
RCA: This was todo item in current code base

Fix: Hello sent with 0 hold time before we update the pim ifp primary address

Signed-off-by: Saravanan K <saravanank@vmware.com>
2020-03-19 03:06:46 -07:00
Donatas Abraitis
15569c58f8 *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__
Just keep the code cool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05 20:23:23 +02:00
Donatas Abraitis
752022670a *: Remove break after return
Just a deadcode.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-13 15:39:54 +02:00
Donald Sharp
06424db447 pimd: Fix possible read beyond end of data received
If a register packet is received that is less than the PIM_MSG_REGISTER_LEN
in size we can have a possible situation where the data being
checksummed is just random data from the buffer we read into.

2019/11/18 21:45:46 warnings: PIM: int pim_if_add_vif(struct interface *, _Bool, _Bool): could not get address for interface fuzziface ifindex=0
==27636== Invalid read of size 4
==27636==    at 0x4E6EB0D: in_cksum (checksum.c:28)
==27636==    by 0x4463CC: pim_pim_packet (pim_pim.c:194)
==27636==    by 0x40E2B4: main (pim_main.c:117)
==27636==  Address 0x771f818 is 0 bytes after a block of size 24 alloc'd
==27636==    at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==27636==    by 0x40E261: main (pim_main.c:112)
==27636==

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-19 08:22:50 -05:00
Satheesh Kumar K
9036d0ef1a pimd: Mark Default TOS Values for PIM & IGMP Outgoing packets
This will facilitate the Hardware to prefer control packets over
Normal Data packets while queuing, so that during congestion, the
chance of dropping control packet will be minimised.

Signed-off-by: Satheesh Kumar K <sathk@cumulusnetworks.com>
2019-09-23 23:03:12 -07:00
saravanank
5acde1cfbf pimd: PIM Bootstrap packet processing
1. Packet validation as per RFC 5059 Sec 3.1.3
We won't supporting scope zone BSM as of now, they are dropped now.
Order of the check slightly be changed in code for optimization.

   if ((DirectlyConnected(BSM.src_ip_address) == FALSE) OR
        (we have no Hello state for BSM.src_ip_address)) {
     drop the Bootstrap message silently
   }

   if (BSM.dst_ip_address == ALL-PIM-ROUTERS) {
     if (BSM.no_forward_bit == 0) {
       if (BSM.src_ip_address != RPF_neighbor(BSM.BSR_ip_address)) {
         drop the Bootstrap message silently
       }
     } else if ((any previous BSM for this scope has been accepted) OR
                (more than BS_Period has elapsed since startup)) {
       #only accept no-forward BSM if quick refresh on startup
       drop the Bootstrap message silently
     }
   } else if ((Unicast BSM support enabled) AND
              (BSM.dst_ip_address is one of my addresses)) {
     if ((any previous BSM for this scope has been accepted) OR
         (more than BS_Period has elapsed since startup)) {
       #the packet was unicast, but this wasn't
       #a quick refresh on startup
       drop the Bootstrap message silently
     }
   } else {
     drop the Bootstrap message silently
   }

2. Nexthop tracking registration for BSR
3. RPF check for BSR Message.
   Zebra Lookup based rpf check for new BSR
   NHT cache(pnc) based lookup for old BSR

Signed-off-by: Saravanan K <saravanank@vmware.com>
2019-05-14 21:40:50 -07:00
saravanank
d57a8bbf45 pimd: PIM Msg header includes N bit as defined by RFC
This commit includes parsing of Nbit and contructing pim hdr with Nbit
Adding Nbit to PIm hdr structure
Adding Scope zone bit and Bidir bit to Encoded IPv4 Group Address

Signed-off-by: Saravanan K <saravanank@vmware.com>
2019-05-14 21:40:50 -07:00
Donald Sharp
75373ccac4 pimd: Move packet_process variable to pim_router
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-04 12:23:39 -05:00
Donald Sharp
36417fcc20 pimd: Create a struct pim_router and move thread master into it
Create a `struct pim_router` and move the thread master into it.
Future commits will further move global varaibles into the pim_router
structure.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-04 12:21:00 -05:00
Quentin Young
1c50c1c0d6 *: style for EC replacements
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:38:57 +00:00
Quentin Young
298004a139 pimd: PIM_[ERR|WARN] -> EC_PIM
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:12:58 +00:00
F. Aragon
dc7204b775
pimd ripd ripngd: variable shadowing fixes
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-12 12:55:31 +02:00
Donald Sharp
8cd3830603 pimd: Add some more useful data to debug output
End user was seeing this debug but we are not giving
the user enough information to debug this on his own.
Add a tiny bit of extra information that could point
the user to solving the problem for themselves.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-28 08:50:55 -04:00
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