Commit Graph

76 Commits

Author SHA1 Message Date
Mark Stapp
5047884528 *: unify thread/event cancel macros
Replace all lib/thread cancel macros, use thread_cancel()
everywhere. Only the THREAD_OFF macro and thread_cancel() api are
supported. Also adjust thread_cancel_async() to NULL caller's pointer (if
present).

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-23 12:16:52 -04:00
Mark Stapp
9bcef951be zebra: replace inet_ntoa
Stop using inet_ntoa - use %pI4 or inet_ntop instead

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-22 13:37:25 -04:00
Donatas Abraitis
2dbe669bdf :* Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 09:07:41 +03:00
David Lamparter
3efd0893d0 *: un-split strings across lines
Remove mid-string line breaks, cf. workflow doc:

  .. [#tool_style_conflicts] For example, lines over 80 characters are allowed
     for text strings to make it possible to search the code for them: please
     see `Linux kernel style (breaking long lines and strings)
     <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_
     and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:37:25 +02:00
Donald Sharp
768e40bde9 zebra: Remvoe typedef for zfpm_glob_t
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08 08:08:04 -04:00
Donald Sharp
a78c2b98f7 zebra: Remove typedef zfpm_msg_format_e
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08 08:08:04 -04:00
Donald Sharp
1d6a3ee83c zebra: Remove the typedef for zfrpm_state_t
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08 08:08:04 -04:00
Donald Sharp
eeaf257b79 zebra: Remove typedef of zfpm_stats_t
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08 08:08:04 -04:00
Donald Sharp
332cba05a3 zebra: Remove typedef around zfpm_rnodes_iter
Typedef's are not used in our system remove.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08 08:08:04 -04:00
Quentin Young
772270f3b6 *: sprintf -> snprintf
Replace sprintf with snprintf where straightforward to do so.

- sprintf's into local scope buffers of known size are replaced with the
  equivalent snprintf call
- snprintf's into local scope buffers of known size that use the buffer
  size expression now use sizeof(buffer)
- sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp
  buffer followed by strlcat

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
David Lamparter
f4b8291fcb *: move CLI node names to cmd_node->name
And again for the name.  Why on earth would we centralize this, just so
people can forget to update it?

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:59 +02:00
David Lamparter
243895805a *: move CLI parent data to cmd_node->parent_node
Same as before, instead of shoving this into a big central list we can
just put the parent node in cmd_node.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
612c2c15d8 *: remove second parameter on install_node()
There is really no reason to not put this in the cmd_node.

And while we're add it, rename from pointless ".func" to ".config_write".

[v2: fix forgotten ldpd config_write]

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
249a771b63 *: remove cmd_node->vtysh
The only nodes that have this as 0 don't have a "->func" anyway, so the
entire thing is really just pointless.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
62b346eefa *: clean up cmd_node initializers
... and use named assignments everywhere (so I can change the struct.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
Ameya Dharkar
44f7f1320c zebra: Address sequencing issue while sending RMAC via FPM
Issue:
For consecutive messages such as
MAC1 -> VTEP1 add
MAC1 -> VTEP2 add
MAC1 -> VTEP1 add

Final state, i.e. (MAC1 -> VTEP1 add) should be sent via FPM.
But, with current code, FPM will send (MAC1 -> VTEP2 add)

RCA:
When FPM receives (MAC1, VTEP1), it stores it in the FPM processing queue and
hash table.

When FPM receives (MAC1, VTEP2), this entry is stored as another node as hash
table key is (mac, vtep and vni)

IF FPM again receives (MAC1, VTEP1), we fetch this node in the hash table
which is already enqueued.

When the FPM queue is processed, we will send FPM message for (MAC1, VTEP1)
first and then for (MAC1, VTEP2)

This sequencing issue happened because the key of the table is (MAC, VTEP, VNI)

Fix:
Change the key of the hash table to (MAC, VNI)
So, every time we receive a new update for (MAC1, VNI1), we will find a node in
the processing queue corresponding to MAC1 if present.
We will update this same node for every operation related to (MAC1, VNI1)

Thus, at the time when FPM processes this node, it will have latest MAC1 info.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2020-04-10 17:59:31 -07:00
Donald Sharp
7f5818fbd6 *: change hash_backet to hash_bucket
It's been a year search and destroy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-28 13:59:13 -05:00
Jafar Al-Gharaibeh
4d67e75282 Revert "*: change hash_backet to hash_bucket"
This reverts commit 3895c42a2e.

LabN CI update needs to be coordinated before merging this

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2020-02-27 09:52:02 -06:00
Donald Sharp
3895c42a2e *: change hash_backet to hash_bucket
It's been a year search and destroy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-26 20:03:34 -05:00
Donald Sharp
f0c459f006 zebra: FPM should have a way of shutting down
When we shut down zebra, we were not doing anything to shut
down the FPM.  Perform the necessary occult rituals and
stop the threads from running during early shutdown.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-18 14:49:46 -05:00
vdhingra
14a4d9d047 Zebra: Rectifying the log messages.
This change addresses the following :
1. Ensures zlog_debug should be under DEBUG macro check
2. Ensures zlog_err and zlog_warn wherever applicable.
3. Removed few posivite logs from fpm handling, whose frequency is high.

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2019-09-19 02:59:04 -07:00
David Lamparter
8b9cf71ce3 zebra/fpm: deprecation warning for protobuf
We agreed on this several weeks ago on the weekly call, I just forgot to
actually put it in a PR...

A call for any Protobuf FPM users to raise their hand came up empty on
both the mailing list as well as Slack.  Let's see if this gets any
response.  If not, it'll be time to remove Protobuf FPM.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-02 20:56:57 +02:00
Quentin Young
2951a7a4c2 *: s/TRUE/true/, s/FALSE/false/
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-07-01 17:26:05 +00:00
Ameya Dharkar
c5431822de Zebra: Address review comments for RMAC FPM feature 1
Address minor review comments.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-06-17 12:05:38 -07:00
Ameya Dharkar
9da60d0a19 Zebra: Build nelink message for RMAC updates
- Function "zfpm_netlink_encode_mac()" builds a netlink message for RMAC updates.

- To build a netlink message for RMAC updates, we use "ndmsg" in rtlink.

- FPM Message structure is:
  FPM header -> nlmsg header -> ndmsg fields -> ndmsg attributes

- Netlink message will look like:
  {'ndm_type': 0, 'family': 7, '__pad': (), 'header': {'flags': 1281,
   'length':64, 'type': 28, 'pid': 0, 'sequence_number': 0}, 'state': 2,
   'flags': 22, 'attrs': [('NDA_LLADDR', 'b2:66:eb:b9:5b:d3'),
   ('NDA_DST', '10.100.0.2'), ('NDA_MASTER', 11), ('NDA_VNI', 1000)],
   'ifindex': 18}

- Message details:
  nlmsghdr.nlmsg_type = RTM_NEWNEIGH(28) or RTM_DELNEIGH(29)
  nlmsghdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_REPLACE for "add" ,
  			 "NLM_F_REQUEST" for delete.
  ndmsg.ndm_family = AF_BRIDGE
  ndmsg.ndm_ifindex = vxlan_if (ifindex)
  ndmsg.ndm_state = NUD_REACHABLE
  ndmsg.ndm_flags |= NTF_SELF | NTF_MASTER | NTF_EXT_LEARNED
  Attribute "NDA_LLADDR" for MAC address
  Attribute "NDA_DST" for remote vtep ip
  Attribute "NDA_MASTER" for bridge interface ifindex.
  Attribute "NDA_VNI" for VNI id.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-06-17 12:05:38 -07:00
Ameya Dharkar
fbe748e59f Zebra: Handle FPM connection up/down events
- When the connection with the FPM socket is established, iterate through all the
  L3VNIs and send all the RMACs for FPM processing zfpm_conn_up_thread_cb"

- We have already handled connection down even in previous commits. When the FPM
  connection goes down, empty mac_q and FPM mac info hash table
  "zfpm_conn_down_thread_cb"

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-06-17 12:05:38 -07:00
Ameya Dharkar
21d814eb0b Zebra: FPM processing of mac_q and dest_q
- FPM write thread calls "zfpm_build_updates()" to process mac_q and dest_q and
  to write update buffer over the FPM socket.

- "zfpm_build_updates()" processes all the update queues one by one in a while
  loop. It will break the while loop and return if Queue processing function
  returns "FPM_WRITE_STOP" OR FPM write buffer is full OR all the queues are
  empty (no more update to process).

- "zfpm_build_route_updates()" dequeues and processes route nodes from "dest_q".

- "zfpm_build_mac_updates()" dequeues and processes MAC nodes from "mac_q"

- These queue processing functions return with "FPM_WRITE_STOP" if the write
  buffer is full. Return value is "FPM_GOTO_NEXT_Q" if enough updates are
  processed from this queue and we want to move on to the next queue.

- In each call, a queue processing function will process max
  "FPM_QUEUE_PROCESS_LIMIT (10000)" updates to avoid starvation of other queues.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-06-17 12:05:38 -07:00
Ameya Dharkar
a780a73896 Zebra: Handle RMAC add/delete operation and add fpm_mac_info_t
- Define a hook "zebra_mac_update" which can be registered by multiple
  data plane components (e.g. FPM, dplane).

DEFINE_HOOK(zebra_rmac_update, (zebra_mac_t *rmac, zebra_l3vni_t *zl3vni, bool
	    delete, const char *reason), (rmac, zl3vni, delete, reason))

- While performing RMAC add/delete for an L3VNI, call "zebra_mac_update" hook.

- This hook call triggers "zfpm_trigger_rmac_update". In this function, we do a
  lookup for the RMAC in fpm_mac_info_table. If already present, this node is
  updated with the latest RMAC info. Else, a new fpm_mac_info_t node is created
  and inserted in the queue and hash data structures.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-06-17 12:05:38 -07:00
Ameya Dharkar
e5218ec873 Zebra: Data structures for RMAC processing in FPM
- FPM MAC structure: This data structure will contain all the information
required for FPM message generation for an RMAC.

struct fpm_mac_info_t {
	struct ethaddr macaddr;
	uint32_t zebra_flags; /* Could be used to build FPM messages */
	vni_t vni;
	ifindex_t vxlan_if;
	ifindex_t svi_if; /* L2 or L3 Bridge interface */
	struct in_addr r_vtep_ip; /* Remote VTEP IP */
	/* Linkage to put MAC on the FPM processing queue. */
	TAILQ_ENTRY(fpm_mac_info_t) fpm_mac_q_entries;
	uint8_t fpm_flags;
};

- Queue structure for FPM processing:
    For FPM processing, we build a queue of "fpm_mac_info_t". When RMAC is
    added or deleted from zebra, fpm_mac_info_t node is enqueued in this queue
    for the corresponding operation. FPM thread will dequeue these nodes one by
    one to generate a netlink message.

    TAILQ_HEAD(zfpm_mac_q, fpm_mac_info_t) mac_q;

- Hash table for "fpm_mac_info_t"
    When zebra tries to enqueue fpm_mac_info_t for a new RMAC add/delete
    operation, it is possible that this RMAC is already present in the queue. So,
    to avoid multiple messages for duplicate RMAC nodes, insert fpm_mac_info_t
    into a hash table.

    struct hash *fpm_mac_info_table;

    - Before enqueueing any MAC, try to fetch the fpm_mac_info_t from the hash
      table first.
    - Entry is deleted from the hash table when the node is dequeued.
    - For hash table key generation, parameters used are "mac adress" and "vni"
      This will provide a fairly unique key for a MAC(fpm_mac_info_hash_keymake).
    - Compare function uses "mac address", "RVTEP address" and "VNI" as the key
      which is sufficient to distinguish any two RMACs. This compare function is
      used for fpm_mac_info_t lookup (zfpm_mac_info_cmp).

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-06-17 12:05:38 -07: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
e914ccbe9c zebra: ZEBRA_[ERR|WARN] -> EC_ZEBRA
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:23:29 +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
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
67aeb55414 zebra: Cleanup compile issues discovered by ci
Include a couple of missed headers.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Quentin Young
43e52561b4 zebra, lib: error references for zebra
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00: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
Donald Sharp
677f704de4 zebra: Add some more debug information on read issues in FPM
When we receive a read failure in handling a FPM read
let's add a bit more information to what we think has
gone wrong, in a hope that debugging will be a bit easier.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-18 09:31:20 -05:00
Donald Sharp
5f7a4718e2 zebra: Replace SELECTED_FIB flag with a rib_dest_t pointer
The SELECTED_FIB flag was placed upon the entry that we
have inserted into the kernel.  Remove this flag and replace
with a `rib_dest_t` *selected_fib.  Just keep track of the
selected_fib as we modify it.  This removes allot of
FOREACH_RE loops as that we do not need to find the
entry anymore.

At this point in time I think this is a very minor performance
boost.  Most `rib_dest_t` structures do not typically carry
more than 1 route_entry, but the minute you start having more
than one entry you can and will start having significant processing
time spent finding the selected_fib.

A future commit may re-order the route entries and possibly
keep more pointers on `rib_dest_t` to avoid lookup.  This
is a bit tricky because of the FIB_OVERRIDE code.

Signed-off-by Donald Sharp <sharpd@cumulusnetworks.com>
2017-12-05 17:26:32 -05:00
Quentin Young
2d34fb80b8
*: don't use deprecated stream.h macros
Some of the deprecated stream.h macros see such little use that we may
as well just remove them and use the non-deprecated macros.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-12-01 13:51:06 -05:00
Donald Sharp
41e7fb8030 lib, ospf6d, ospfd, zebra: Add ZEBRA_STR
Allow us to use a ZEBRA_STR for commands

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25 10:57:00 -04:00
Thorvald Natvig
c6bbea179b Send all routes to FPM, including VRF and multicast
Signed-off-by: Thorvald Natvig <thorvald@medallia.com>
2017-10-19 23:55:41 -07: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
9d1c265929 zebra: don't print 0.0.0.0:0 for FPM config
Fixes: #319
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-23 20:17:45 +02: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
David Lamparter
55f70b671f *: remove VTYNL, part 4 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:03 +02:00
David Lamparter
61b7d449bd *: remove VTYNL, part 3 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:03 +02:00
David Lamparter
5c7571d43f *: ditch vty_outln(), part 1 of 2
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13 20:29:22 +02:00
Quentin Young
1318e7c841 *: s/VTY_NEWLINE/VTYNL/g
Should be able to fit more vty_out onto one line now

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:34:54 +00:00
Quentin Young
96ade3ed77 *: use vty_outln
Saves 400 lines

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:31:28 +00:00
Quentin Young
a587d00bac *: remove THREAD_BACKGROUND
it's just an alias for a millisecond timer used in exactly nine places
and serves only to complicate

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-08 01:53:50 +00:00