Commit Graph

289 Commits

Author SHA1 Message Date
Renato Westphal
4068787842 ripd: retrofit the 'route' command to the new northbound model
Trivial conversion. Remove the rip->route routing table and associated
code because this variable was used only to show the running
configuration.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
908f002092 ripd: retrofit the 'redistribute' commands to the new northbound model
Trivial conversion. As usual, combine multiple DEFUNs into a single
DEFPY for simplicity.

As a bonus of the northbound conversion, this commit fixes the
redistribution of certain protocols into ripd. The 'redist_type' array
used by the "redistribute" commands was terribly outdated, which was
preventing the CLI to parse correctly certain protocols like isis
and babel.

Remove the route_map hooks installed by rip_route_map_init() since they
were redundant (rip_init() already takes care of that).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
44f2f852a1 ripd: retrofit the 'passive-interface' command to the new northbound model
In ripd, the "passive-interface default" command has the following
behavior:
* All interfaces are converted to the passive mode;
* The "passive-interface IFNAME" command becomes a no-operation and
  "passive-interface IFNAME" statements are removed from the running
  configuration.
* The "no passive-interface IFNAME" can be used to remove interfaces
  from the passive mode.

This command was modeled using the following YANG data nodes in the
frr-ripd module:

  leaf passive-default {
    type boolean;
    default "false";
    description
      "Control whether interfaces are in the passive mode
       by default or not.";
  }
  leaf-list passive-interface {
    when "../passive-default = 'false'";
    type string {
      length "1..16";
    }
    description
      "A list of interfaces where the sending of RIP packets
       is disabled.";
  }
  leaf-list non-passive-interface {
    when "../passive-default = 'true'";
    type string {
      length "1..16";
    }
    description
      "A list of interfaces where the sending of RIP packets
       is enabled.";
  }

The 'when' statements guarantee that the list of passive interfaces
is cleared when the "passive-interface default" command is entered
(likewise, they guarantee that the list of non-passive interfaces is
cleared when the "passive-interface default" command is removed). This
matches exactly the behavior we want to model.

Finally, move the 'passive_default' global variable into the
'rip' structure where it belongs. This fixed the bug where the
"passive-interface default" command was being retained after a "no router
rip" + "router rip".

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
8c942f6506 ripd: retrofit the 'offset-list' command to the new northbound model
Remove the rip_offset_list_set() and rip_offset_list_unset() functions
since they set/unset multiple configuration options at the same time. The
northbound callbacks need to set/unset configuration options individually.

The frr-ripd YANG module models the "offset-list" command using a list
keyed by the 'interface' and 'direction' leafs. One important detail is
that the IFNAME parameter is optional, and when it's not present it means
we want to match all interfaces. This is modeled using an interface name
of '*' since key lists are mandatory by definition in YANG.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
3d7a1be850 ripd: retrofit the 'network' command to the new northbound model
The frr-ripd YANG module models the ripd "network" command using two
separate leaf-lists for simplicity: one leaf-list for interfaces and
another leaf-list for actual networks. In the 'cli_show' callbacks,
display the "network" command for entries of both leaf-lists.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
23b23d8c27 ripd: retrofit the 'distance source' commands to the new northbound model
The "distance (1-255) A.B.C.D/M [WORD]" command was modeled using a
YANG list, which makes it a little bit more complicated to convert to
the new northbound model.

The rip_distance_set() and rip_distance_unset() functions were removed
since they set/unset multiple configuration options at the same time. The
northbound callbacks need to set/unset configuration options individually.

When a distance list is created, use yang_dnode_set_entry() to store
a pointer in the configuration node, and retrieve this pointer in the
other callbacks using yang_dnode_get_entry().

The 'rip_distance' structure was moved to ripd.h so that it can be used
in the rip_northbound.c file.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
7f8a9cbab7 ripd: retrofit the 'distance' command to the new northbound model
Trivial conversion.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
282ae30c4a ripd: retrofit the 'default-metric' command to the new northbound model
Trivial conversion.

rip->default_metric was converted to an uint8_t to match the way it's
defined in the YANG module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
0b0609ba35 ripd: retrofit the 'default-information' command to the new northbound model
Trivial conversion.

'rip->default_information_route_map' was removed since it wasn't being
used anywhere.

'rip->default_information' was removed too because it was being used only
to display the running configuration and thus is not necessary anymore.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
edbf59d209 ripd: retrofit the 'allow-ecmp' command to the new northbound model
Trivial conversion. The rip->ecmp variable was converted to a boolean to
match the way it's defined in the YANG module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
8c9226c216 ripd: retrofit the 'router rip' command to the new northbound model
* Implement the northbound callbacks associated to the
  '/frr-ripd:ripd/instance' YANG path (the code is mostly a copy and paste
  from the original "router rip" DEFUNs);
* Move rip_create_socket() out of rip_create() since creating a socket
  is an error-prone operation and thus needs to be performed separately
  during the NB_EV_PREPARE phase;
* On rip_create(), fetch the defaults from the frr-ripd YANG model;
* Convert the "[no] router rip" CLI commands to be dumb wrappers around
  the northbound callbacks;
* On config_write_rip(), write logic to call all 'cli_show' northbound
  callbacks defined under the '/frr-ripd:ripd/instance' YANG path.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
David Lamparter
0437e10517 *: spelchek
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-25 20:10:57 +02:00
David Lamparter
6a154c8812 *: list_delete_and_null() -> list_delete()
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02 11:40:52 +02: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
450971aa99 *: LIB_[ERR|WARN] -> EC_LIB
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:34:28 +00:00
Quentin Young
993c8024ff ripd: RIP_[ERR|WARN] -> EC_RIP
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:14:28 +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
David Lamparter
633fc9b133 *: frr_elevate_privs whitespace fixes
(... and one superfluous variable removed)

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
David Lamparter
01b9e3fd0d *: use frr_elevate_privs() (1/2: coccinelle)
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
Quentin Young
09c866e34d *: rename ferr_zlog -> flog_err_sys
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +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
518e377f39 ripd: Add RIP_ERR_XXX to move from zlog_err to zlog_ferr
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Donald Sharp
77cbe4a1b3 ripd: Convert zlog_err to zlog_ferr for LIB_ERR_XXX
For those errors that can be traced to LIB_ERR_XXX
convert to using those in ripd.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Quentin Young
aad95a7dc2 ripd: re-add check for rip_create fail
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-11 17:14:58 +02:00
Donald Sharp
0ce1ca805d *: ALLOC calls cannot fail
There is no need to check for failure of a ALLOC call
as that any failure to do so will result in a assert
happening.  So we can safely remove all of this code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-11 17:14:58 +02:00
lyq140
558c6842f7 ripd: fix packet sending in authenticate mode
fix a bug when sending packets.
in authenticate mode but without any string,
no packet should send.

Signed-off-by: lyq140 <34637052+lyq140@users.noreply.github.com>
2018-08-06 14:14:00 +08:00
lyq140
ac000da998 ripd: fix packet sending
fix a bug when sending a rip packet.
in authenticate mode but without any string,
no packet should send.

Signed-off-by: lyq140 <34637052+lyq140@users.noreply.github.com>
2018-08-06 10:46:58 +08:00
lyq140
c4efb22479 ripd: null check key
Fix ripd crash of null pointer.
when authenticate a rip packet,
the key pointer or the key string pointer may be null,
the code have to return then.

Signed-off-by: lyq140 <34637052+lyq140@users.noreply.github.com>
2018-08-01 20:48:36 +08:00
lyq140
e65e227f28 ripd: null check the key string
This fix a crash of  null pointer.
when we don't add a key string or delete it,
the key is not null but key string is null,
so the code have to return.

Signed-off-by: lyq140 <34637052+lyq140@users.noreply.github.com>
2018-08-01 12:03:24 +08:00
paco
0961ea934f
ripd: out-of-bounds read (Coverity 1399295)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-22 19:16:52 +02:00
Donald Sharp
b260862317 ripd: Intentionally ignore return from rip_send_packet
Coverity SA has noticed that we are not ignoring the return
codes from rip_send_packet in one case.  Since we do not care
let the system know we don't.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 10:42:05 -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
lyq140
9920df072a ripd: considering a interface with 2 or more IP
This commit fixes these three issues:

1) rinfo is used for rip packet sending not tmp_rinfo
2) With RIP_SPLIT_HORIZON and an interface with more than 1 ip addresses
we will not send the routes out an interface that they originate on
3) With RIP_SPLIT_HORIZON_POISONED_REVERSE and an interface with
more than 1 ip address we will not send out ipA with a metric of 16
and ipb with a metric of 1.  Both will be 16 now.

Signed-off-by: lyq140 <34637052+lyq140@users.noreply.github.com>
2018-03-21 07:46:36 -04: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
aea175a8f4 ripd: Fix crash when ip rip split-horizon poisoned-reverse is configed
The code was attempting to access a variable that would always be NULL.
In fact this code has been broken since the rip ECMP changes
were put into place a few years back.

I'm going to come straight out and say that I don't fully
understand this code.  rinfo is the first item in the ecmp
list and tmp_rinfo is used to iterate over all the items
in the ecmp list.  It sure looks like that the changes
made here were just hacked together.  So I modified
the tmp_rinfo loop to just work on tmp_rinfo and
the check that was crashing I modified to just use
the rinfo since that what was checked originally
in code before the ECMP was added.  So consider
this a hack job to stop the crashing.

I think worse case is that we might be sending some routes
back out interfaces it shouldn't be if you have
ip rip split-horizon poisoned-reverse configured but
that is less bad(tm) than crashing.

Fixes: #1717
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-07 08:27:34 -05:00
Donald Sharp
11ff71648e ripd: Fix SA issues
The rinfo variable was being set but never used.

We just need to call rip_ecmp_replace or rip_ecmp_add
this function does not care about the return values
because the rinfo returned is stored on the rip
route entry.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-16 08:49:02 -05:00
Donald Sharp
14aa0c3d3a ripd: Fix spelling mistake in debug
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-16 08:45:28 -05:00
Donald Sharp
3f5682c88d ripd: Allow rip_redistribute_add to know the nexthop type
Allow rip_redistribute_add to receive and properly store
the nexthop type passed up from zebra.

Additionally display the different nexthop types appropriately.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-16 08:45:28 -05:00
Donald Sharp
dd127197f9 ripd: Convert to using 'struct nexthop' for nexthop information
RIP is not using the nexthop data structure and as such when
it does not fully understand when it receives some of the
more exotic nexthop types what to do with it.  This is the
start of a series of commits to allow RIP to start understanding
and properly displaying information about different nexthop
types.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-16 08:45:28 -05:00
Donald Sharp
32b5a49362 ripd: Make 'struct zebra_privs_t' available
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-23 18:09:23 -04:00
Renato Westphal
451fda4f9a *: use the FOR_ALL_INTERFACES abstraction from babeld
This improves code readability and also future-proofs our codebase
against new changes in the data structure used to store interfaces.

The FOR_ALL_INTERFACES_ADDRESSES macro was also moved to lib/ but
for now only babeld is using it.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:46 -03:00
Renato Westphal
f4e14fdba7 *: use rb-trees to store interfaces instead of sorted linked-lists
This is an important optimization for users running FRR on systems with
a large number of interfaces (e.g. thousands of tunnels). Red-black
trees scale much better than sorted linked-lists and also store the
elements in an ordered way (contrary to hash tables).

This is a big patch but the interesting bits are all in lib/if.[ch].

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:02 -03:00
Donald Sharp
acdf5e2510 *: Convert list_free usage to list_delete
list_free is occassionally being used to delete the
list and accidently not deleting all the nodes.
We keep running across this usage pattern.  Let's
remove the temptation and only allow list_delete
to handle list deletion.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:53:17 -04:00
Donald Sharp
affe9e9983 *: Convert list_delete(struct list *) to ** to allow nulling
Convert the list_delete(struct list *) function to use
struct list **.  This is to allow the list pointer to be nulled.

I keep running into uses of this list_delete function where we
forget to set the returned pointer to NULL and attempt to use
it and then experience a crash, usually after the developer
has long since left the building.

Let's make the api explicit in it setting the list pointer
to null.

Cynical Prediction:  This code will expose a attempt
to use the NULL'ed list pointer in some obscure bit
of code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:53:13 -04:00
Donald Sharp
00c9a53ddc ripd: Free leaked memory on shutdown
Usage of the address sanitizer and topotests showed
that rip was leaking obuf on shutdown

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-21 09:40:46 -04:00
Renato Westphal
8941a38520 Merge pull request #1078 from dwalton76/ospfd-network-cmd-warning
*: return CMD_WARNING if command was already configured
2017-08-31 13:23:25 -03:00
Daniel Walton
851fcbaebe *: return CMD_WARNING if command was already configured
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

If the user configures some command that is already in the config we
should return CMD_WARNING instead of CMD_WARNING_CONFIG_FAILED
2017-08-31 15:14:01 +00: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
David Lamparter
9d303b37d7 Revert "*: reindent pt. 2"
This reverts commit c14777c6bf.

clang 5 is not widely available enough for people to indent with.  This
is particularly problematic when rebasing/adjusting branches.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-22 14:52:33 +02:00
whitespace / reindent
c14777c6bf
*: reindent pt. 2
w/ clang 5

* reflow comments
* struct members go 1 per line
* binpack algo was adjusted
2017-07-17 15:26:02 -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
David Lamparter
2d8270596a Merge remote-tracking branch 'frr/master' into newline-redux
Lots of conflicts from CMD_WARNING_CONFIG_FAILED...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 13:07:30 +02:00
David Lamparter
625e016d14 *: remove VTYNL, part 6 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:03 +02:00
David Lamparter
6d3c2ed4ed *: remove VTYNL, part 1 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:02 +02:00
David Lamparter
181039f3d7 *: ditch vty_outln(), part 2 of 2
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:19:58 +02:00
Daniel Walton
f1a05de982 vtysh: return non-zero for configuration failures
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

This allows frr-reload.py (or anything else that scripts via vtysh)
to know if the vtysh command worked or hit an error.
2017-07-13 19:56:08 +00: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
e31b6333f4 *: vty_outln (vty, "") --> vty_out (vty, VTYNL)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:34:56 +00: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
56b4067930 *: simplify log message lookup
log.c provides functionality for associating a constant (typically a
protocol constant) with a string and finding the string given the
constant. However this is highly delicate code that is extremely prone
to stack overflows and off-by-one's due to requiring the developer to
always remember to update the array size constant and to do so correctly
which, as shown by example, is never a good idea.b

The original goal of this code was to try to implement lookups in O(1)
time without a linear search through the message array. Since this code
is used 99% of the time for debugs, it's worth the 5-6 additional cmp's
worst case if it means we avoid explitable bugs due to oversights...

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-21 15:22:21 +00: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
Hung-Weic Chiu
c16b6d31ed Address the error "Dead assignment" of static analysif
- Refer to https://ci1.netdef.org/browse/FRR-FRR4-44/artifact/shared/static_analysis/index.html
- Remove unused variable

Signed-off-by: Hung-Weic Chiu <sppsorrg@gmail.com>
2017-05-10 16:02:48 -04:00
Quentin Young
66e78ae64b *: update thread_add_* calls
Pass pointer to pointer instead of assigning by return value. See
previous commit message.

To ensure that the behavior stays functionally correct, any assignments
with the result of a thread_add* function have been transformed to set
the pointer to null before passing it. These can be removed wherever the
pointer is known to already be null.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-09 20:44:22 +00: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
b3cfe637a6 Merge pull request #294 from opensourcerouting/modules
Loadable module support
2017-04-04 11:55:00 -04:00
David Lamparter
505e50567f *: apply DEFUN_NOSH for node-switch CLI commands
These have copies in vtysh that do the node-switch locally and are
listed in extract.pl's ignore list.  The ignore list however is
redundant since DEFUN_NOSH does the same thing...

ldpd is a bit hacky, but Renato is reworking this anyway.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-28 15:48:07 -04:00
David Lamparter
5986b66b82 *: snmp: convert into modules
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-25 08:52:36 +01:00
Donald Sharp
baaea325e6 *: Refactor ifindex2ifname to be VRF aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:43:21 -04:00
Donald Sharp
1306c09a1b *: Refactor if_lookup_by_name to be VRF aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:36:23 -04:00
Donald Sharp
95af5f130a lib, ospfd, ripd: Convert if_lookup_address to be vrf aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:31:10 -04:00
David Lamparter
4f04a76b71 *: add frr_init() infrastructure
Start centralising startup & option parsing into the library.

FRR_DAEMON_INFO is a bit weird, but it will become useful later (e.g.
for killing the ZLOG_* enum, and having the daemon name available)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-07 23:07:20 +01:00
Donald Sharp
7df2e1c379 Merge remote-tracking branch 'origin/stable/2.0' 2017-02-07 13:20:12 -05:00
Donald Sharp
d904a9fc09 ripd: Fix compile warning
This issue was found compiling with ./buildtest.sh
on fedora 25

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-03 08:29:21 -05:00
David Lamparter
cdc2d76507 *: coccinelle-replace vty->index
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-09 17:36:25 +01:00
David Lamparter
f6eacff438 ripd: add qobj registrations
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-09 17:36:25 +01: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
8578874d69 ripd: minor code simplification
* Simplify the RIP_TIMER_OFF macro and use it on more places;
* Be more explicit when creating the RIP UDP socket - cosmetic change
  since socket(AF_INET,SOCK_DGRAM,0) defaults to UDP on every known
  UNIX/Linux platform.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-25 11:46:06 -02:00
Renato Westphal
043144ea89 ripd: make use of the IP_MULTICAST_LOOP sockoption
We still need to check for self-generated packets on rip_read() because
ripd may also send broadcast packets. But using IP_MULTICAST_LOOP on the
ripd socket will at least prevent us from receiving a lot unnecessary
multicast packets when RIPv2 is being used, thus improving performance.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-25 11:46:06 -02:00
Renato Westphal
ae735d2d0e ripd: fix race condition on input processing
In the early days of ripd, we supported running RIP on secondary IP
addresses. To do that, everytime we needed to send a multicast packet,
we would create a new temporary socket for each of the interface's
addresses and call bind() to change the source IP of the outgoing packets.

The problem with these temporary sockets is that they are more specific
than the global RIP socket (bound to INADDR_ANY). Then, even though these
sockets only exist for a short amount of time, they can receive some RIP
packets that were supposed to be received on the global RIP socket. And
since we never read from the temporary sockets, these packets are dropped.

Since we don't support secondary addresses anymore, the simplest way to
fix this problem is to stop using temporary sockets for sending multicast
packets. We are already setting IP_MULTICAST_IF before sending each
multicast packet, and in this case the primary address of the selected
interface is used as the source IP of the outgoing packets, which is
exactly what we want.

If we decide to reintroduce support for secondary addresses in the future,
we should try one of the following:
* Use IP_SENDSRCADDR/IP_PKTINFO to set the source address of the outgoing
  multicast packets;
* Create one permanent UDP socket for each possible interface address,
  and enable reading on all sockets.

Fixes the following IxANVL RIP tests: 7.10 and 14.1.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-25 11:46:06 -02:00
Renato Westphal
b10ce84103 ripd: fix the "neighbor" command.
We can't use if_lookup_prefix() in rip_update_process() because this
function uses prefix_cmp() internally to try matching an interface
address to a static neighbor's address.

Since prefix_cmp() tries to match exact prefixes, if_lookup_prefix()
was always returning NULL.

What we really need here is to use prefix_match(), which checks if
one prefix includes the other (e.g. one /24 interface including a /32
static neighbor's address). The fix then is to replace the call to
if_lookup_prefix() and use if_lookup_address() instead, which uses
prefix_match() internally.

Fixes IxANVL RIP test 17.1

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-25 11:46:06 -02:00
Renato Westphal
6aec4b4176 ripd: add "none" option to the "ip rip receive version" command
RFC 2453 says (section 5.1):
"(...) For completeness, routers should also implement a receive control
switch which would determine whether to accept, RIP-1 only, RIP-2 only,
both, or none.  It should also be configurable on a per-interface basis".

For the "ip rip send version" command, we don't need to implement the
"none" option because there's already the "passive-interface" command
for that.

Fixes IxANVL RIP test 16.8.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-25 11:45:39 -02:00
Renato Westphal
f90310cfe8 ripd: implement the "ip rip v2-broadcast" CLI command
This command allows ripd to send v2 updates as broadcast packets instead
of multicast packets. Useful as a technique to help with RIPv1/v2
interop issues.

Fixes IxANVL RIP test 16.2

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-25 11:34:39 -02:00
Renato Westphal
4e0548665d ripd: ignore request for RTEs from unknown address-families
Fixes IxANVL RIP test 6.5.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-25 11:34:39 -02:00
Renato Westphal
1cfaf93c5e ripd: reject authentication strings with zeros in the middle
RFC 2453 says:
"If the password is under 16 octets, it must be left-justified and padded
to the right with nulls (0x00)".

Fixes IxANVL RIP test 10.3.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-25 11:34:39 -02:00
Quentin Young
39e92c066f Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	bgpd/bgp_encap.c
	bgpd/bgp_route.c
	lib/command.c
	lib/command.h
	ospf6d/ospf6d.c
	vtysh/vtysh.c
2016-10-21 19:27:49 +00:00
Christian Franke
58093a7917 ripd: print md5 auth digest correctly
The dump of the md5 hash was missing one byte of the hash.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-20 20:28:26 -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
Donald Sharp
0b1442e37b *: Consolidate all double VIEW_NODE and ENABLE_NODE's
If a command is put into the VIEW_NODE, it is going into the
ENABLE_NODE as well.  This is especially true for show commands.
As such if a command is in both consolidate it down to VIEW_NODE.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-07 21:05:06 -04:00
Christian Franke
9471675f21 ripd: add support for route tags
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-10-07 21:05:05 -04:00
Christian Franke
dc9ffce878 *: Consistently support 32-bit route tags
This patch improves zebra,ripd,ripngd,ospfd and bgpd so that they can
make use of 32-bit route tags in the case of zebra,ospf,bgp or 16-bit
route-tags in the case of ripd,ripngd.

It is based on the following patch:

    commit d25764028829a3a30cdbabe85f32408a63cccadf
    Author: Paul Jakma <paul.jakma@hpe.com>
    Date:   Fri Jul 1 14:23:45 2016 +0100

    *: Widen width of Zserv routing tag field.

But also contains the changes which make this actually useful for all
the daemons.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-10-07 21:05:05 -04:00
Quentin Young
55c727dd75 ripd, ripngd: cli refactor
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-27 00:10:31 +00:00
Matthieu Boutier
fb23cf4abe lib: Make distribute.c accepts both v4 and v6.
distribute.c doesn't allow to manage both v4 and v6 distribute lists.  This
patch fix this problem by having 4 DISTRIBUTE* values in the enumeration instead
of two. The code in all daemons using distribute.c is adapted.
2016-09-26 10:52:41 -04:00
Matthieu Boutier
7c989d74b5 ripd: code simplification for redistribution.
Use loops and variables instead of doing each cases by hand.
Use boolean instead of having 2 almost identical functions.
2016-09-26 10:52:41 -04:00
Daniel Walton
80fa0c69e8 ripd: add 'int idx_foo' argv index variables
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 20:06:40 +00:00
Paul Jakma
1dec2166de ripd: split-horizon default differed between rip_interface_new and _reset
* rip_interface.c: Default for split_horizon_default differed between
  rip_interface_new and rip_interface_reset, causing at least some issues
  after interface events. See patchwork #604. Fix, and consolidate code.

  (rip_interface_{reset,clean}) rename these to 'interface', as that's more
  appropriate.  Spin the ri specific bodies of these functions out to
  rip_interface_{reset,clean} helpers.  Factor out the overlaps, so
  rip_interface_reset uses rip_interface_clean.

  (rip_interface_new) just use rip_interface_reset.

* ripd.h: Update for (rip_interface_{reset,clean})

Reported by xufeng zhang, with a suggested fix on which this commit expands.
See patchwork #604.  This commit addresses only the split-horizon
discrepency, issue #2.  The other issue they reported, #1, is not addressed,
though suggested fix seems inappropriate.

Cc: xufeng.zhang@windriver.com
2016-09-23 12:12:16 -04:00
Daniel Walton
6147e2c694 convert <1-255> to (1-255), ()s to <>s, etc
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 13:47:20 +00:00
Daniel Walton
f412b39a33 ALIAS removal for bgp, ospf, pim, isis, rip, ripng, lib and zebra
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 03:55:26 +00:00
Daniel Walton
558e4c284b ripd: argv update
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 00:01:25 +00:00
Daniel Walton
30814472b6 Revert "ripd: Fixup code to work under new way"
This reverts commit 224a3ed809.
2016-09-22 18:21:43 +00:00
Donald Sharp
224a3ed809 ripd: Fixup code to work under new way 2016-09-20 23:41:24 -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
b06fd12526 Quagga: Fix code to use srandom/random
Quagga was using a mix of srand/rand and srandom/random.
Consolidate to use srandom/random which are the POSIX
versions of random number generators

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-29 20:24:55 -04:00
Lu Feng
8478ae7ef3 ripd: allow to enable/disable the ECMP feature
Introduce a new command "[no] allow-ecmp" to enable/disable the
ECMP feature in RIP. By default, ECMP is not allowed.

Once ECMP is disabled, only one route entry can exist in the list.

* rip_zebra.c: adjust a debugging information, which shows the number
               of nexthops according to whether ECMP is enabled.
* ripd.c: rip_ecmp_add() will reject the new route if ECMP is not
          allowed and some entry already exists.
          A new configurable command "allow-ecmp" is added to control
          whether ECMP is allowed.
          When ECMP is disabled, rip_ecmp_disable() is called to
          remove the multiple nexthops.
* ripd.h: Add a new member "ecmp" to "struct rip", indicating whether
          ECMP is allowed or not.

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 0b74a0a5db7bcf65bf68c44b547b02b1310b5cdb)
2016-05-26 17:12:05 +00:00
Lu Feng
bce8e8681a ripd: add ECMP support
* Each node in the routing table is changed into a list, holding
  the multiple equal-cost paths.

* If one of the multiple entries gets less-preferred (greater
  metric or greater distance), it will be directly deleted instead
  of starting a garbage-collection timer for it.
  The garbage-collection timer is started only when the last entry
  in the list gets INFINITY.

* Some new functions are used to maintain the ECMP list. And hence
  rip_rte_process(), rip_redistribute_add() and rip_timeout() are
  significantly simplified.

* rip_zebra_ipv4_add() and rip_zebra_ipv4_delete() now can share
  the common code. The common part is moved to rip_zebra_ipv4_send().

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 b397cf4f0fc484c5ebfc8a680090055c8e6cbe32)

Conflicts:
	ripd/rip_zebra.c
2016-05-26 17:11:05 +00:00
Lu Feng
6a7cff75c6 ripd: use only one constant for derivation
RIP_MAX_RTE is defined in ripd.h as 25 but is in fact the
result of a formula. More over it is not used in the code:
the code itself includes the fomula. This makes it un-clear
for maintenance.

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 342a31bfda)
2016-05-26 01:06:37 +00:00
Donald Sharp
bd40c341ee lib: refactor connected_lookup_prefix
The connected_lookup_address function should really
be a connected_lookup_prefix function.  Refactor
the code to use it.

Ticket: CM-10890
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-05-12 10:03:44 -04:00
Donald Sharp
b2d7c082a2 quagga: Remove iflist global variable
The file if.c has a iflist that had the list of interfaces
in the default vrf.  Remove this variable and replace
with a vrf_iflist lookup on the default vrf where it
was used.

Additionally, modify ptm code to iterate over all vrf's
when enabling ptm.

Ticket: CM-10338
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Radhika Mahankali <radhika@cumulusnetworks.com>
2016-04-08 13:15:59 -04:00
Christian Franke
85b123a4bf ripd, isisd: fix warnings that make the build fail
These issues have been found by running buildtest.sh
using GCC 5.2.0 and Clang 3.7.0

Fixes pointer checks that can never be null

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Tested-by: NetDEF CI System <cisystem@netdef.org>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-03-29 20:26:11 -04:00
Donald Sharp
4608cb43b1 quagga: Additional centos 6 -enable-werror fixes
This commit fixes these warnings:

1) bgpd/bgp_nexthop.c - dereferencing pointer 'X' does break strict-aliasing rules
3) ripd/ripd.c - 'ifaddr.prefixlen' may be used uninitialized in this function

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-09-29 06:36:04 -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
7ce2a26cd7 Fixup of some last remaining differences between stg and git 2015-07-22 13:12:22 -07:00
Donald Sharp
e5f745ca93 ripd: ripd-warnings.patch
Remove compile warnings for the ripd directory
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:
2015-05-19 18:29:14 -07:00
Lu Feng
342a31bfda ripd: use only one constant for derivation
RIP_MAX_RTE is defined in ripd.h as 25 but is in fact the
result of a formula. More over it is not used in the code:
the code itself includes the fomula. This makes it un-clear
for maintenance.

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>
2014-07-02 19:30:20 +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
Lu Feng
7b3b98ae3e ripd & ripngd: avoid the zero interface metric
The interface metric is initialized to 0 in the commit db19c85:
zebra: set metric for directly connected routes via netlink to 0

Ripd and ripngd must be aware of it and avoid increase the
route metric by 0.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-06-03 15:32:11 +02:00
David Lamparter
b68da446e9 ripd: correctly redistribute ifindex routes (BZ#664)
ripd had a check to restrict metric 0 to only directly connected routes.
This check was implemented by checking against Connected as route type.
This is, however, incorrect -- all routes that directly use an interface
without a nexthop should be treated as directly connected and passed off
with metric 0.

ripngd does not posess such a check and was not touched.

Reported-by: Sean Fulton <sean@gcnpublishing.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-04-09 22:33:19 +02:00
Nick Hilliard
bb2315f287 ripd: clear sockaddr_in before using
ripd_create_socket() failed in bind() on Mac OS X 10.7 since there was garbage
in unused fields of struct sockaddr_in.

* ripd/ripd.c: zero out struct sockaddr_sin from before filling.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-09-25 06:03:46 +02:00
Stephen Hemminger
2c2397059d ripd: fix compiler warnings
* ripd/rip_interface.c
  * rip_request_neighbor(): comment out, unused
  * rip_request_neighbor_all(): idem
  * rip_interface_up(): Cast flags otherwise compiler complains
    about %lld not matching uint64_t on 64 bit x86. Print in hex
    since flags are bit field.
  * rip_interface_add(): idem
  * rip_interface_delete(): idem
* ripd/rip_zebra.c
  * rip_redistribute_set(): comment out, unused
* ripd/ripd.h
  * rip_redistribute_check(): move prototype here so compiler
    can check function against prototype
* ripd/ripd.c
  * rip_update_default_metric(): comment out, unused
2009-12-10 19:16:05 +03:00
Stephen Hemminger
78b31d5cf5 ripd: set IP TOS for control socket
* ripd.c: (rip_create_socket) RIP packets should go out with Type Of Service
  (DSCP) set to Internet control (like OSPF and BGP).
2009-07-27 12:37:26 +01:00
Stephen Hemminger
82f5ee1ead [ripd] Ignore non-running interfaces in rip status
Vyatta Bug 3999
2009-06-18 20:18:27 +01:00
Stephen Hemminger
7fc626de5f [cleanup] Make command nodes static
The cmd_nodes used to configure vty, can mostly be static so
(basic data hiding 101).
2009-06-12 17:10:29 +01:00
Stephen Hemminger
393deb9bd6 [cleanup] Convert XMALLOC/memset to XCALLOC
Simple conversion of XMALLOC/memset to XCALLOC
2009-06-12 17:07:49 +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
Paul Jakma
fa93b16208 [ripd] Fix mistaken empty string test
2008-05-29 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* ripd.c: (rip_auth_md5) fix bogus empty string test
2008-05-29 19:03:08 +00:00
Paul Jakma
ce6ab03a27 [ripd] remove unnecessary 0 entries from struct message's
2008-03-13 Paul Jakma <paul.jakma@sun.com>

	* ripd.c/rip_interface.c: Remove 0 entries from rip_msg
	  ri_version_msg struct message's, not needed with recent fixes
	  to mes_lookup.
2008-03-13 03:28:13 +00:00
Paul Jakma
6f0e3f6e17 [autoconf] bugs 162,303,178: Fix 'present but can not be compiled' warnings
2007-05-09 Paul Jakma <paul.jakma@sun.com>

	* configure.ac: sys/conf.h depends on sys/param.h, at least on
	  FBSD 6.2.
	  (bug #363) Should check for in_pktinfo for IRDP

2006-05-27 Paul Jakma <paul.jakma@sun.com>

	* configure.ac: General cleanup of header and type checks, introducing
	  an internal define, QUAGGA_INCLUDES, to build up a list of
	  stuff to include so as to avoid 'present but cant be compiled'
	  warnings.
	  Misc additional checks of things missing according to autoscan.
	  Add LIBM, for bgpd's use of libm, so as to avoid burdening
	  LIBS, and all the binaries, with libm linkage.
	  Remove the bad practice of using m4 changequote(), just
	  quote the []'s in the case statements properly.
	  This should fix bugs 162, 303 and 178.
	* */*.{c,h}: Update all HAVE_* to the standard autoconf namespaced
	  HAVE_* defines. I.e. HAVE_SA_LEN -> HAVE_STRUCT_SOCKADDR_SA_LEN,
	* bgpd/Makefile.am: Add LIBM to bgpd's LDADD, for pow().
2007-05-10 02:38:51 +00:00
Andrew J. Schorr
33672eddf1 [ripd, ripngd] Remove useless code in rip_vty_out_uptime function
2007-04-27 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

	* ripd/ripd.c: (rip_vty_out_uptime) Remove unused variable timer_now.
	* ripngd/ripngd.c: (ripng_vty_out_uptime) Remove unused variable
	  timer_now.
2007-04-27 18:03:11 +00:00
Vincent Jardin
a1fdf94796 Fix the display of route timeout in "show ip rip". (Use thread_timer_remain_second) 2007-04-11 15:12:05 +00:00
Andrew J. Schorr
a4c648281d [ripd] Fix "show ip rip status" display of time until next update
2007-03-21 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

	* ripd.c: (show_ip_rip_status) Use new thread_timer_remain_second
	  function instead of rip_next_thread_timer to display the time until
	  next update properly.
	  (rip_next_thread_timer) Remove obsolete function.
2007-03-21 18:57:38 +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
3e557ae1ea [ripd] bug #278: remove gratuitous use of mid-function declaration
2006-09-11 Paul Jakma <paul.jakma@sun.com>

	* ripd.c: (rip_read) remove gratuitous use of mid-function
	  declaration of vrecv, bug #278.
2006-09-11 02:10:40 +00:00
Paul Jakma
15a2b089ce [ripd] bugs #261, #262: Fix RIPv1 info-leak and unauthenticated route updates
2006-05-04 Paul Jakma <paul.jakma@sun.com>

	* (general) Fixes for bugs #261 and 262. Thanks to
	  Konstantin V. Gavrilenko <kos@arhont.com> for the problem
	  reports, testing of a series of proposed patches and comment
	  on the proposed changes in behaviour.
	* rip_interface.c: (ip_rip_authentication_mode_cmd) Parse all
	  of the command before making any changes to configured state.
	* ripd.c: (rip_read) RIP version control should be absolute and
          always apply, fixes bug #261 by allowing RIPv1 to be disabled.
	  Fix bug #262: If authentication is enabled, then
	  unauthenticated packets should not be accepted. We do however
	  make an exception for RIPv1 REQUEST packets, to which we will
	  reply as RIPv1 can now be disabled fully, to allow ripd to
	  still provide routing /information/ to simple devices.
2006-05-04 07:36:34 +00:00
Andrew J. Schorr
b9d92881f5 [ripd] Fix logic to send updates on all connected addresses.
2006-04-28 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

	* ripd.c: (rip_update_process) Try to fix the logic for sending
	  an updated on each connected network.  The new code will
	  attempt to send the update on each connected network, whereas
	  the previous code seemed to be attempting to avoid sending
	  more than one RIPv1 update on a given interface, but was coded
	  incorrectly.  The actual effect of the old code was to send
	  an update only on the first connected address in the cases
	  where the interface is not multicast, or RIPv2 is not being used.
2006-04-28 16:22:36 +00:00
vincent
7a38333957 ripd.c: correct bug that allowed route learnt through RIP to take precedence over connected routes 2006-01-30 18:12:42 +00:00
paul
98fd1e6121 [ripd] Fix verification of received MD5 authenticated packets
2006-01-17 Paul Jakma <paul.jakma@sun.com>

	* ripd.c: (rip_auth_md5) remove pdigest, not needed.
	  Use a local buffer for the auth_str, where it can be properly
	  nul padded. Do so, hence fixing MD5 authentication.
	  Key looked up via key ring should be used in preference to
	  the RIPv1 simple password, not other way around.
	  No need to copy around digests, we can reference them
	  directly.
	  The auth_len received can't be trusted, some implementations
	  lie (e.g. older ripd).
	  (rip_auth_md5_ah_write) rename len local variable to doff
	  to be consistent with other functions.
	  (rip_auth_header_write) add the missing return.
	  (rip_auth_md5_set) use the proper constructs to access stream.
2006-01-17 17:26:25 +00:00
ajs
35a60c2d3c 2005-10-30 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* ripd.c: (rip_response_process) Instead of calling
	  rip_interface.c:if_valid_neighbor(), call the equivalent
	  library function if_lookup_address().
	* rip_interface.c: (if_valid_neighbor) Remove function, since it is
	  essentially equivalent to the if_lookup_address() library function.
	* ripd.h: (if_valid_neighbor) Remove function declaration.
2005-10-30 23:51:32 +00:00
paul
216565ab68 2005-10-26 Paul Jakma <paul.jakma@sun.com>
* ripd.c: Update couple more functions to specify void
	  explicitely.
2005-10-25 23:35:28 +00:00
paul
dc63bfd495 2005-10-26 Paul Jakma <paul.jakma@sun.com>
* (general) static/extern functions and definitions.
	* rip_interface.h: new file, export the public functions from
	  rip_interface.c
2005-10-25 23:31:05 +00:00
jardin
38d3c163cf 2005-10-17 Vincent Jardin <vincent.jardin@6wind.com>
* ripd.c: rip_create_socket() for each packet, it does not bind to the
          proper interfaces because we forget to use the from address when
          it is specified.
2005-10-19 19:29:59 +00:00
ajs
f52d13cb2e 2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
	  zebra_route_char().
	* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
	  functions to map zebra route numbers to strings.
	* zebra_vty.c: (route_type_str) Remove obsolete function: use new
	  library function zebra_route_string() instead.  Note that there
	  are a few differences: for IPv6 routes, we now get "ripng" and
	  "ospf6" instead of the old behavior ("rip" and "ospf").
	  (route_type_char) Remove obsolete function: ues new library function
	  zebra_route_char() instead.  Note that there is one difference:
	  the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
	  whereas the new one returns 'X'.
	  (vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
	  route_type_str() with zebra_route_string().
	  (vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
	  with zebra_route_char().
	* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
	  zebra_route_string instead of a local hard-coded table.
	* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
	  zroute_abname. Change the ZROUTE_NAME macro to use new library
	  function zebra_route_string().  Remove the ZROUTE_ABNAME macro.
	  (ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
	  a call to zebra_route_char(), and be sure to fix the format string,
	  since we now have a char instead of a char *.
	* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
	  zebra_route_abname.  Note that the zebra_route_name[] table
	  contained mixed-case strings, whereas the zebra_route_string()
	  function returns lower-case strings.
	  (ospf6_zebra_read_ipv6): Change debug message to use new library
	  function zebra_route_string() instead of zebra_route_name[].
	  (show_zebra): Use new library function zebra_route_string() instead
	  of zebra_route_name[].
	* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
	  (ospf_redist_string) New function implemented using new library
	  function zebra_route_string().  Note that there are a few differences
	  in the output that will result: the new function returns strings
	  that are lower-case, whereas the old table was mixed case.  Also,
	  the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
	  new function returns "ospf6".
	* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
	  and add extern const char *ospf_redist_string(u_int route_type)
	  instead.
	* ospf_asbr.c: (ospf_external_info_add) In two messages, use
	  ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
	* ospf_vty.c: Remove local hard-coded table distribute_str.
	  (config_write_ospf_redistribute,config_write_ospf_distribute): Use
	  new library function zebra_route_string() instead of distribute_str[].
	* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
	  ospf_redistribute_default_set,ospf_redistribute_check)
	  In debug messages, use ospf_redist_string() instead of
	  LOOKUP(ospf_redistributed_proto).
	* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
	  table str[]. Replace str[] with calls to new library function
	  zebra_route_string().
	* ripd.c: Remove local hard-coded table route_info[].
	  (show_ip_rip) Replace uses of str[] with calls to new library
	  functions zebra_route_char and zebra_route_string.
	* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
	  table str[].  Replace str[i] with new library function
	  zebra_route_string(i).
	* ripngd.c: Remove local hard-coded table route_info[].
	  (show_ipv6_ripng) Use new library function zebra_route_char() instead
	  of table route_info[].
2005-10-01 17:38:06 +00:00
vincent
fbf5d03304 2005-09-29 Alain Ritoux <alain.ritoux@6wind.com>
* lib/filer.c: show protocol name in filter_show()
    * lib/plist.c: show protocol name in vty_show_prefix_entry()
    * routemap.c: show protocol name in vty_show_route_map_entry()
    * lib/vty.c: in vty_command(), show protocol name if command unknown

    * zebra/zserv.c: Always provide distance fo route add

    * ripd/rip_snmp.c: rip2IfConfReceive() sends values in conformance
      with RFC. Also PeerDomain is now set to a STRING type.
    * ripd/ripd.h: rip_redistribute_add() API includes metric and distance
    * ripd/ripd.c: rip_redistribute_add() API i.e. stores metric and distance
      Now allows a RIP-route to overcome a redistributed route coming
      from a protocol with worse (higher) administrative distance
      Metrics from redistribution are shown in show ip rip
    * ripd/rip_zebra.c: adapt to the rip_redistribute_add() API, i.e.
      provide distance and metric
    * ripd/rip_interface.c: adapt to the rip_redistribute_add() API
    * ripd/rip_routemap.c: no RMAP_COMPILE_ERROR on (metric > 16) usage
      rather a CMD_WARNING, because set metric ius shared with other
      protocols using larger values (such as OSPF)
      The match metric action takes first external metric if present
      (from redistribution) then RIP metric.
2005-09-29 11:25:50 +00:00
vincent
c1a03d4774 2005-09-28 Alain Ritoux <alain.ritoux@6wind.com>
* lib/md5-gnu.h: removed
    * lib/md5.h: replaces md5-gnu.h
    * lib/Makefile.am: use correct md5.h
    * lib/md5.c: import from WIDE
    * ospfd/ospf_packet.c: use new md5 API
    * ripd/ripd.c: use new md5 API
2005-09-28 15:47:44 +00:00
paul
2c61ae3782 2005-08-16 Paul Jakma <paul.jakma@sun.com>
* ripd.c: (general) Fix previous commit, broke multicast bind and
	  hence setting of source port, which broke communication with
	  non-borken ripd. Fix removes more stuff from rip_interface.c
	  than it adds to ripd.c ;)
	  (rip_create_socket) the to argument really is a from argument,
	  rename it. Set the source port to RIP port unconditionally, it's
	  required.
	  (rip_send_packet) Set from address correctly for multicast.
	  (rip_output_process) trivial: num can be BSS specified, rather
	  than in body.
	* rip_interface.c: (rip_interface_multicast_set) strip out
	  redundant stuff related to bind, which rip_create_socket does.
	  Just make it set the multicast socket option, as per the
	  interface concerned, no more.
2005-08-16 15:22:14 +00:00
paul
f69bd9da8b 2005-06-03 Paul Jakma <paul.jakma@sun.com>
* ripd.c: (rip_create_socket) Make it static.
	  Remove the getservbyname stuff, as RFC2453 3.9.2 says non-RIP
	  port messages should be discarded, quagga doesnt accept them,
	  no need to lookup port.
	  Take a 'to' argument, if socket should be bound to something else.
	  setsockopt_so_recvbuf might need privs, move it to the raised
	  privileges section.
	  dont forget to close the socket if bind fails.
	  (rip_send_packet) use strncpy, just in case (address is under
	  our control anyway, but still).
	  dont duplicate rip_create_socket - just use it.
	  (rip_create) rip_create_socket takes an argument now, modify.
2005-06-03 18:01:50 +00:00
paul
a4e987e0b0 2005-06-03 Paul Jakma <paul.jakma@sun.com>
* ripd.c: (rip_create_socket) move it up so rip_send_packet
	  can use it too.
2005-06-03 17:46:49 +00:00
paul
0cb8a01c38 2005-05-29 Paul Jakma <paul@dishone.st>
* ripd.c: (rip_output_process) fix error which crept in my
	  previous rip auth untanglement commit - it had become impossible
	  to not have authentication (even for v1).
2005-05-29 11:27:24 +00:00
paul
1eb8ef2584 2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
	  and some basic auditing of usage.
	* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
	* HACKING: Add notes about deprecating interfaces and commands.
	* lib/linklist.h: Add usage comments.
	  Rename getdata macro to listgetdata.
	  Rename nextnode to listnextnode and fix its odd behaviour to be
	  less dangerous.
	  Make listgetdata macro assert node is not null, NULL list entries
          should be bug condition.
          ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
          with for loop, Suggested by Jim Carlson of Sun.
          Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
          "safety" of previous macro.
	  LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
	  distinguish from the similarly named functions, and reflect their
	  effect better.
	  Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
	  with the old defines which were modified above,
	  for backwards compatibility - guarded to prevent Quagga using it..
	* lib/linklist.c: fix up for linklist.h changes.
	* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
	  scan of the area list, rather than scanning all areas first for
	  INTER_ROUTER and then again for INTER_NETWORK. According to
	  16.2, the scan should be area specific anyway, and further
	  ospf6d does not seem to implement 16.3 anyway.
2005-04-07 07:30:20 +00:00
paul
9985f83ce7 2005-02-09 Paul Jakma <paul.jakma@sun.com>
* (global) Update code to match stream.h changes.
	  stream_get_putp effectively replaced with stream_get_endp.
	  stream_forward renamed to stream_forward_getp.
	  stream_forward_endp introduced to replace some previous
	  setting/manual twiddling of putp by daemons.
	* lib/stream.h: Remove putp. Update reference to putp with endp.
	  Add stream_forward_endp, which daemons were doing manually.
	  Rename stream_forward to stream_forward_getp.
	  lib/stream.c: Remove/update references to putp.
	  introduce stream_forward_endp.
2005-02-09 15:51:56 +00:00
paul
b14ee00b7f 2005-02-04 Paul Jakma <paul@dishone.st>
* ripd.c: Untangle the construction of RIP auth data.
	  (rip_auth_prepare_str_send) new helper function, prepare
	  correct key string.
	  (rip_auth_simple_write) new helper, write out the
	  rip simple password auth psuedo-RTE.
	  (rip_auth_md5_ah_write) new helper, write out the
	  MD5 auth-header psuedo-RTE.
	  (rip_auth_header_write) new helper, write out correct
	  auth header data / psuedo-RTE.
	  (rip_auth_md5_set) rip out the memmove and writing of the
	  auth header psuedo-RTE. So that all that is left is to
	  write the trailing auth digest, and update digest offset
	  field in the original header.
	  (rip_write_rte) rip out writing of RIP header, writing of
	  simple auth data psuedo-RTE. Make it do what its name suggests,
	  write out actual RTEs.
	  (rip_output_process) remove the incorrect additional decrements
	  of rtemax. Prepare the auth_str, which simple or MD5 auth will
	  need. Move write out of RIP header and auth data to inside the
	  loop. Adjust paramaters as required.
2005-02-04 23:42:41 +00:00