Commit Graph

358 Commits

Author SHA1 Message Date
David Lamparter
7d3d2de465 lib: add sockopt helper for setting IPV6_V6ONLY and use it
getaddrinfo returns a list of socket parameters for listening. it
will contain both IPv4 and IPv6 listening sockets. unless we use
IPV6_V6ONLY on the IPv6 ones, only the socket listed first will
work. if the IPv4 one came first, the IPv6 one would get an
"Address in use" error.

this functionality was already present for bgpd and its listening
sockets. as it is needed for vtys as well, make it a common helper.
2011-11-21 18:25:01 +04:00
David Lamparter
daca2cf463 lib: put route_types.txt to real use
this replaces most occurences of routing protocol lists by preprocessor
defines from route_types.h. the latter is autogenerated from
route_types.txt by a perl script (previously awk). adding a routing
protocol now is mostly a matter of changing route_types.txt and log.c.

Conflicts:

	lib/route_types.awk
2011-11-21 18:24:50 +04:00
David Lamparter
d9ddd5731d bgpd: remove unused function bgp_bind_address
bgp_bind_address is replaced with sockunion_bind.
2011-11-21 18:23:34 +04:00
David Lamparter
5d3c53b999 bgpd: fix update-source for IPv6 (BZ#548)
if update-source was given as interface name, bgpd was unconditionally
trying to bind to an IPv4 address from that interface.

change function to find the best-matching (number of address bits)
same-family address on the interface.
2011-11-21 18:23:24 +04:00
Dylan Hall
8b1eb59bb9 bgpd: fix "nexthop-local unchanged" (BZ#350) 2011-11-15 21:31:25 +04:00
Chris Luke
90d181bd1a bgpd: justify capabilities for TOS setting
To set the TOS bits on TCP connections, platforms that restrict
capabilities need the priv level to be raised before the sockopt
is set, and this requires the ZCAP_NET_ADMIN priv.

* bgp_main.c: update _caps_p to include ZCAP_NET_ADMIN
* bgp_network.c
  * bgp_connect(): request ZPRIVS_RAISE/ZPRIVS_LOWER
  * bgp_listener(): request ZPRIVS_RAISE earlier
2011-11-15 21:26:07 +04:00
Sergey Y. Afonin
f85bab1482 bgpd: revised fix to --dryrun (BZ#622) 2011-11-15 20:34:01 +04:00
Denis Ovsienko
7ebd47095b bgpd: fix more regressions in attr flag checks
Commit 05a4936b713b9882171d0f7fb20b8439df23939e fixed some of the
attributes involved, but not all. This commit should do it.

* bgp_attr.c
  * bgp_attr_originator_id()
  * bgp_attr_cluster_list()
  * bgp_mp_reach_parse()
  * bgp_mp_unreach_parse()
2011-10-19 17:27:07 +04:00
John Kemp
cc0b6c122f bgpd: improve "monotonic" uptime correction
Older versions of Quagga/Zebra would output a value in MRT table
dump files for "uptime" aka "ORIGINATED" that was a WALL clock
value.  Given that uptime is now internally a bgp_clock MONOTONIC
value, the output in the MRT files is showing up as monotonic.

Note: time of MRT dump is still recorded correctly as a
time() based value, so we haven't lost that value.

Proposal is to correct the uptime output on the vty and in the
MRT files to again display something more akin to WALL time.

* bgp_dump.c: (bgp_dump_routes_func) add conditional correction
* bgp_route.c: (route_vty_out_detail) make correction conditional, move
  variable declaration to beginning of the function
2011-10-17 18:42:19 +04:00
Denis Ovsienko
efb2c331e7 bgpd: add flag checks for MP_(UN)REACH_NLRI
* bgp_attr.[ch]
  * bgp_mp_reach_parse(): add extra arguments and a uniform flag
    check block
  * bgp_mp_unreach_parse(): idem
  * bgp_attr_parse(): provide extra arguments
* bgp_mp_attr_test.c
  * parse_test(): justify respective calls
2011-10-17 18:31:12 +04:00
Denis Ovsienko
047d6a601f bgpd: improve attr length error handling (BZ#679)
* bgp_attr.c
  * bgp_attr_parse(): provide extra argument to bgp_attr_aggregator()
  * bgp_attr_local_pref(): use bgp_notify_send_with_data()
  * bgp_attr_atomic(): idem
  * bgp_attr_aggregator(): idem
2011-10-17 18:31:01 +04:00
Denis Ovsienko
452db84a79 bgpd: fix spelling of CLUSTER_LIST 2011-10-17 18:30:52 +04:00
Denis Ovsienko
cadc4cf05d bgpd: check CLUSTER_LIST attribute flags
* bgp_attr.c
  * bgp_attr_cluster_list(): accept extra argument, add checks for
    "optional", "transitive" and "partial" bits, log each error
    condition independently
  * bgp_attr_parse(): provide extra arguments
2011-10-17 18:28:36 +04:00
Denis Ovsienko
5de1719994 bgpd: check ORIGINATOR_ID attribute flags
* bgp_attr.c
  * bgp_attr_originator_id(): accept extra argument, add checks for
    "optional", "transitive" and "partial" bits, log each error
    condition independently
  * bgp_attr_parse(): provide extra arguments
2011-10-17 18:28:24 +04:00
Denis Ovsienko
566941f953 bgpd: fix regression in improved attr flag checks
Commit 2febf323411c1aed9d7694898f852ce2ef36a7e5 assumed every flag
bit except optional/transitive/partial unset, which at times could
not be true for "extended length" bit.

* bgp_attr.c
  * bgp_attr_origin(): exclude BGP_ATTR_FLAG_EXTLEN from comparison
  * bgp_attr_nexthop(): idem
  * bgp_attr_med(): idem
  * bgp_attr_local_pref(): idem
  * bgp_attr_atomic(): idem
2011-10-17 18:28:10 +04:00
Denis Ovsienko
395ec7f5ab bgpd: improve attr flags checks
Do not check each of the Optional/Transitive/Partial attribute
flag bits, when their only valid combination is known in advance,
but still perform bit-deep error message logging. This change
assumes unused (low-order) 4 bits of the flag octet cleared.

* bgp_attr.c
  * bgp_attr_origin(): rewrite check
  * bgp_attr_nexthop(): idem
  * bgp_attr_med(): idem
  * bgp_attr_local_pref(): idem
  * bgp_attr_atomic(): idem
2011-10-17 18:27:55 +04:00
Denis Ovsienko
e531d4a662 bgpd: add missing "partial" flag checks (BZ#676)
ORIGIN handling function used to have "partial" bit check and recent
commits added it for NEXT_HOP, MULTI_EXIT_DISC and ATOMIC_AGGREGATE
cases. This commit adds "partial" check for AS_PATH and LOCAL_PREF
cases, which should leave attributes 1 through 6 inclusive completely
covered with attribute flags checks.

* bgp_attr.c
  * bgp_attr_origin(): use bit-by-bit checks for better diagnostics
  * bgp_attr_aspath(): add flag check
  * bgp_attr_local_pref(): idem
2011-10-17 18:27:44 +04:00
Denis Ovsienko
19e7654a29 bgpd: ignore 4 bits of attribute flags byte 2011-10-17 18:27:32 +04:00
Stephen Hemminger
d1e2faa40e IPv6 transport class suppport
IPv6 supports the same concept of differentiated service for routing
protocols as IPv4, but like too many things, the standards committee
decided that having two names for the same thing wasn't good enough and
introduced a third more generic term transport class.

The socket option to set transport class works the same as IPv4, but the
arguments are different.

* lib/sockopt.[ch]
  * setsockopt_ipv6_tclass(): new function
* bgpd/bgp_network.c
  * bgp_connect(): set socket option
  * bgp_listener(): set socket option
* ospf6d/ospf6_network.c
  * ospf6_set_transport_class(): new function
  * ospf6_serv_sock(): set socket option
* ripngd/ripngd.c
  * ripng_make_socket(): set socket option
2011-10-17 18:13:28 +04:00
CROSS
a1afbc6e1d bgpd: CVE-2011-3327 (ext. comm. buffer overflow)
This vulnerability (CERT-FI #513254) was reported by CROSS project.
They have also suggested a fix to the problem, which was found
acceptable.

The problem occurs when bgpd receives an UPDATE message containing
255 unknown AS_PATH attributes in Path Attribute Extended Communities.
This causes a buffer overlow in bgpd.

* bgp_ecommunity.c
  * ecommunity_ecom2str(): perform size check earlier
2011-09-26 18:39:37 +04:00
Denis Ovsienko
3eca6f099d bgpd: improve NEXT_HOP attribute checks (BZ#680)
* lib/prefix.h
  * IPV4_CLASS_DE(): new helper macro
* bgp_attr.c
  * bgp_attr_nexthop(): add check for "partial" bit, refresh flag error
    reporting, explain meaning of RFC4271 section 6.3 and implement it
2011-09-25 18:18:25 +04:00
Dmitrij Tejblum
c347846e4f bgpd: don't be confused by "unspecific" subcode in the NOTIFY message.
* bgp_debug.c (bgp_notify_open_msg, bgp_notify_update_msg,
  bgp_notify_cease_msg, bgp_notify_capability_msg): add messages for
  "unspecific" subcode.
2011-09-25 18:17:50 +04:00
Denis Ovsienko
ca22cc4cc3 bgpd: check ATOMIC_AGGREGATE attr flags (BZ#678)
* bgp_attr.c
  * bgp_attr_atomic(): accept extra argument, add checks for
    "optional", "transitive" and "partial" bits, log each error
    condition independently
  * bgp_attr_parse(): provide extra argument
2011-09-25 18:17:24 +04:00
Denis Ovsienko
7d25f1883f bgpd: check MULTI_EXIT_DISC attr flags (BZ#677)
* bgp_attr.c
  * bgp_attr_med(): add checks for "optional", "transitive" and
    "partial" bits, log each error condition independently
2011-09-25 18:17:03 +04:00
Denis Ovsienko
d0511bd9b0 bgpd: check LOCAL_PREF attribute flags (BZ#674)
* bgp_attr.c
  * bgp_attr_local_pref(): accept extra argument, add checks for
    "optional" and "transitive" bits, log each error condition
    independently
  * bgp_attr_parse(): provide extra argument
2011-09-25 18:16:51 +04:00
Peter Pentchev
74ffab30c3 bgpd: fix parsing of graceful restart cap. (#663)
"While setting up a testbed, I ran across a little problem in the
parsing of the "graceful restart" BGP capability that resulted in
Quagga not actually activating it for the peer in question - when
the peer sent a single AFI/SAFI block."

* bgp_open.c
  * bgp_capability_restart(): actually process the last AFI/SAFI block
2011-09-25 18:13:40 +04:00
heasley
2e35e96a11 bgpd: add useful notification logs (BZ#616)
* bgp_packet.c
  * bgp_notify_send_with_data(): add calls to zlog_info()
2011-09-25 18:13:14 +04:00
Denis Ovsienko
6787978cc8 bgpd: spelling 2011-09-10 21:50:53 +04:00
Denis Ovsienko
71008de7c8 bgpd: spelling 2011-09-10 16:53:30 +04:00
Denis Ovsienko
22aefb2270 bgpd: improve "show ip bgp scan detail"
* bgp_nexthop.c (show_ip_bgp_scan_tables): access proper structure field
  in AF_INET6 case, handle ifindex NH type properly
2011-08-09 14:42:58 +04:00
Denis Ovsienko
15b1d9d0b0 bgpd: dismiss some zlookup checks
bgp_nexthop_onlink(): zlookup is not used here at all
bgp_nexthop_lookup_ipv6(): rely on the detection performed by "query"
  function (this also changes the fallback value to 0), reorder if-block
bgp_nexthop_lookup(): idem
2011-08-08 19:36:44 +04:00
Denis Ovsienko
5990281d4e bgpd: add "show ip bgp scan detail" command
* bgp_nexthop.c: (show_ip_bgp_scan) transform into
  show_ip_bgp_scan_tables(), which uses inet_ntop() and can dump
  nexthops on request; (show_ip_bgp_scan_detail_cmd) new function
2011-08-05 21:47:08 +04:00
Denis Ovsienko
5c98c5a7b1 bgpd: touch nexthop handling code
bgp_nexthop_lookup_ipv6(): declare variables where they are actually
used, drop no-op initialization (the field is already 0)
bgp_nexthop_lookup(): ditto
bgp_nexthop_check_ebgp(): rename to bgp_nexthop_onlink()
bgp_nexthop_cache_changed(): rename to bgp_nexthop_cache_different()
2011-08-05 18:52:52 +04:00
Stephen Hemminger
0ddff5764f bgpd: use XCALLOC to allocate bgpd damp array
* bgpd: (bgp_damp_parameter_set) The BGP reuse_index is not initialized
  properly.  This would cause sporadic crash when disabling dampening.  Use
  XCALLOC correctly and the right size array is initialized and no memset is
  needed.
2011-08-03 16:56:42 +04:00
Wataru Tanitsu
f4ac0fee73 bgpd: Fix display of unsigned attributes
* bgp_route.c: (route_vty_out*) The local prefix, metric and weight values
  are all stored as uint32_t.  Change the format to %u so that large values
  are not displayed as negative integers.
2011-08-01 15:36:36 +04:00
Paul Jakma
a8b79422aa bgpd: Fix compile failure if IPv6 build was disabled.
* bgp_route.c: ({no_,}ipv6_bgp_network_ttl_cmd) depends on ipv6_bgp_network
  which is HAVE_IPV6, so these should be too.
  (bgp_route_init) and the installs should be similarly ifdefed
2011-07-18 10:39:02 +04:00
Denis Ovsienko
fdc38db248 bgpd: rename SAFI 3 according to RFC4760
- SAFI value 3 is reserved.  It was assigned by RFC 2858 for a use
  that was never fully implemented, so it is deprecated by this
  document.

* zebra.h: rename macro
* bgp_fsm.c: (bgp_graceful_restart_timer_expire,
  bgp_graceful_stale_timer_expire, bgp_stop, bgp_establish): update
* bgpd.c: (peer_nsf_stop): update
* bgp_open.c: (bgp_capability_vty_out): SAFI 3 isn't a recognized case
  any more
2011-07-17 19:33:21 +04:00
Denis Ovsienko
e81537d3be bgpd: more SAFI fixes
Two macros resolving to the same integer constant broke a case block and
a more thorough merge of BGP_SAFI_VPNV4 and BGP_SAFI_VPNV6 was
performed.

* bgpd.h: MPLS-labeled VPN SAFI is AFI-independent, switch to single
* macro
* bgp_capability_test.c: update test data
* bgp_mp_attr_test.c: idem
* bgp_route.c: (bgp_maximum_prefix_overflow, bgp_table_stats_vty) update
  macro and check conditions (where appropriate)
* bgp_packet.c: (bgp_route_refresh_send, bgp_capability_send,
  bgp_update_receive, bgp_route_refresh_receive): idem
* bgp_open.c: (bgp_capability_vty_out, bgp_afi_safi_valid_indices,
  bgp_open_capability_orf, bgp_open_capability): idem
* bgp_attr.c: (bgp_mp_reach_parse, bgp_packet_attribute,
  bgp_packet_withdraw): idem
2011-07-14 12:36:19 +04:00
Denis Ovsienko
87f011e529 bgpd: fix SAFI for for MPLS labeled VPN-IPv6
* bgpd.h: change value of BGP_SAFI_VPNV6 to 128 (RFC4659, BZ#659)
* bgp_route.c: (bgp_table_stats_vty) fix length argument to strncmp()
2011-07-13 16:53:13 +04:00
heasley
ea15b20a7c bgpd: consistent log msg format (BZ#565) 2011-07-12 20:09:18 +04:00
Paul Jakma
e70e575a8c bgpd: Remove AS Path limit/TTL functionality
* draft-ietf-idr-as-pathlimit doesn't seem to have gone anywhere, and its
  author does not think it will make progress in IDR. Remove all support
  introduced for it, but leave stubs for the commands to avoid breaking
  any configurations.

  Basically reverts cecab5e9725792e60a5e4b473e238a14cd85815d.
(cherry picked from commit c8f3fe3063)

Conflicts:

	bgpd/bgp_attr.c (caused by c8e7b895, resolved)
2011-07-05 00:41:59 +04:00
Paul Jakma
fc09716b81 bgpd/security: CVE-2010-1674 Fix crash due to extended-community parser error
* bgp_attr.c: (bgp_attr_ext_communities) Certain extended-community attrs
  can leave attr->flag indicating ext-community is present, even though no
  extended-community object has been attached to the attr structure.  Thus a
  null-pointer dereference can occur later.
  (bgp_attr_community) No bug fixed here, but tidy up flow so it has same
  form as previous.

  Problem and fix thanks to anonymous reporter.
(cherry picked from commit 0c46638122)
2011-07-04 21:02:00 +04:00
David Ward
16ac59798e bgpd: VTY string fixes for debug commands
* bgpd/bgp_debug.c: fix VTY strings for BGP debug commands to match
  correct syntax
(cherry picked from commit 6e22b9017e)
2011-07-04 21:02:00 +04:00
Dmitrij Tejblum
bbccf41f8e bgpd: fix handling of "Unsupported Capability"
* bgp_packet.c: (bgp_notify_receive) justify the difference between
BGP_NOTIFY_OPEN_UNSUP_PARAM and BGP_NOTIFY_OPEN_UNSUP_CAPBL cases, as
it is explained in RFC5492, page 3, paragraph 1.

"Unsupported Capability" error does not mean, that the peer doesn't
support capabilities advertisement -- quite the opposite (if the peer
would not support capabilities advertisement, the code would be
"Unsupported Optional Parameter"). Thus there is no reason to mark
the peer as one non-supporting capabilities advertisement.

Example: suppose the peer is in fact IPv6-only, but we didn't configure
anything address-family specific for it. Then, the peer would refuse
the session with "Unsupported Capability" code. If we internally set
the peer as non-supporting capabilities advertisement after that, we
will not be able to establish the session with it ever, even with a
fixed configuration -- IPv6-only BGP session cannot be established
without capabilities.

In practice an edge case would be seen as the same IPv6 peer working
with its "neighbor" block read from bgpd.conf, but not working, when
slowly input in "conf t" mode.
(cherry picked from commit c7aa8abd87)
2011-07-04 21:02:00 +04:00
Denis Ovsienko
dfc1d5caac bgpd: fix community-list error message spelling
* bgp_vty.c: (community_list_perror, show_ip_community_list_arg,
  show_ip_extcommunity_list_arg) fix spelling
(cherry picked from commit b729294c8c)
2011-07-04 21:02:00 +04:00
Vladimir L Ivanov
213b6cd9fb bgpd: fix printed value of last-update timestamp
* bgp_route.c: (route_vty_out_detail) calculate time value
    in a way, which works regardless of monotonic clock
    being used or not
2010-10-21 14:59:54 +04:00
Michael Lambert
4c9641ba4d bgpd, lib: adopt afi_t and safi_t in several places
* bgpd/bgp_attr.c, bgpd/bgp_open.h, bgpd/bgp_route.c, lib/prefix.c,
  lib/prefix.h: Various integer types were being used where, if we
  had strict type checking, afi_t and safi_t would be required.

Signed-off-by: G.Balaji <balajig81@gmail.com>
(cherry picked from commit c8af35ffa2dc79ff7d7ff00b1b61f1f50a100ab6)
2010-10-06 12:33:05 -04:00
Greg Troxel
d3ddb22e90 Set from even if binfo->extra is NULL.
bgpd/bgp_packet.c:bgp_update_packet(): When extracting the peer, don't
  fail to extract it because "binfo->extra" is NULL.  While one should
  certainly avoid dereferencing binfo->extra, that's not a good reason
  not to use binfo->peer.

Fixes https://bugzilla.quagga.net/show_bug.cgi?id=497.
Patch by Eric Sobocinksi.
2010-09-17 10:47:49 -04:00
Chris Hall
cddb8112b8 bgpd: fix handling of AS path data
* bgpd/bgp_aspath.c
  * assegments_parse(): add handling of AS4_PATH input, update bounds
    checks, add check for AS segment type
  * aspath_parse(): add handling of AS4_PATH input, expect
    assegments_parse() to do length checking
  * aspath_empty(): update for the new function prototype
* bgpd/bgp_aspath.h: ditto
* tests/aspath_test.c: ditto
* bgpd/bgp_attr.c
  * bgp_attr_aspath(): add handling of AS4_PATH input, update flags
    checks, change returned type
  * bgp_attr_as4_path(): discard, superseded by bgp_attr_aspath()
  * bgp_attr_parse(): update respectively
2010-08-09 22:31:37 +04:00
Chris Hall
d64379e8f3 bgpd: tighten bounds checking in RR ORF msg reader
* bgp_packet.c: (bgp_route_refresh_receive) add validation of
  "Length" (RFC5292) field value, check input stream bounds
  each time bytes are pulled from it
2010-05-14 16:38:39 +04:00