Date: Fri, 2 Nov 2012 13:06:15 +0000 (UTC) From: Sergey Matveychuk <sem@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r306847 - in head/net/quagga: . files Message-ID: <201211021306.qA2D6FOZ025881@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sem Date: Fri Nov 2 13:06:15 2012 New Revision: 306847 URL: http://svn.freebsd.org/changeset/ports/306847 Log: - Add an optional patch to allow 'set ip next-hop' in route maps for OSPF announces. This is useful for OSPF with CARP. Submitted by: glebius Approved by: maintainer Feature safe: yes Added: head/net/quagga/files/extra-patch-ospf-nexthop (contents, props changed) Modified: head/net/quagga/Makefile Modified: head/net/quagga/Makefile ============================================================================== --- head/net/quagga/Makefile Fri Nov 2 12:17:41 2012 (r306846) +++ head/net/quagga/Makefile Fri Nov 2 13:06:15 2012 (r306847) @@ -34,7 +34,7 @@ MAN8= bgpd.8 ospf6d.8 ospfd.8 ripd.8 ri INFO= quagga OPTIONS_DEFINE= ISISD PAM OSPF_OPAQUE_LSA RTADV SNMP TCPSOCKETS DLMALLOC \ - NO_BGP_ANNOUNCE + NO_BGP_ANNOUNCE OSPF_NEXTHOP ISISD_DESC= Enable experimental ISIS daemon PAM_DESC= PAM authentication for vtysh @@ -43,6 +43,7 @@ RTADV_DESC= IPv6 Router Advertisements TCPSOCKETS_DESC= Use TCP/IP sockets for protocol daemons DLMALLOC_DESC= Use dlmalloc (makes bgpd much faster) NO_BGP_ANNOUNCE_DESC= Turn off BGP route announcement +OSPF_NEXTHOP_DESC= Set ip next-hop in OSPF route maps .include <bsd.port.options.mk> @@ -127,6 +128,11 @@ SUB_LIST= RCLDCONFIG= CONFIGURE_ARGS+=--disable-bgp-announce .endif +.if ${PORT_OPTIONS:MOSPF_NEXTHOP} +post-patch: + @${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-ospf-nexthop +.endif + USE_RC_SUBR= quagga watchquagga SUB_LIST+= LOCALSTATE_DIR=${LOCALSTATE_DIR} \ Added: head/net/quagga/files/extra-patch-ospf-nexthop ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/quagga/files/extra-patch-ospf-nexthop Fri Nov 2 13:06:15 2012 (r306847) @@ -0,0 +1,175 @@ +diff -Nur ./ospfd/ospf_asbr.c /tmp/quagga-0.99.20-patched/ospfd/ospf_asbr.c +--- ./ospfd/ospf_asbr.c 2011-09-29 16:59:32.000000000 +0400 ++++ /tmp/quagga-0.99.20-patched/ospfd/ospf_asbr.c 2012-01-15 18:44:18.000000000 +0400 +@@ -122,6 +122,7 @@ + { + values->metric = -1; + values->metric_type = -1; ++ values->nexthop.s_addr = -1; + } + + int +diff -Nur ./ospfd/ospf_asbr.h /tmp/quagga-0.99.20-patched/ospfd/ospf_asbr.h +--- ./ospfd/ospf_asbr.h 2011-09-29 16:59:32.000000000 +0400 ++++ /tmp/quagga-0.99.20-patched/ospfd/ospf_asbr.h 2012-01-15 18:44:18.000000000 +0400 +@@ -27,6 +27,7 @@ + { + int32_t metric; + int32_t metric_type; ++ struct in_addr nexthop; + }; + + /* Redistributed external information. */ +@@ -50,6 +51,7 @@ + struct route_map_set_values route_map_set; + #define ROUTEMAP_METRIC(E) (E)->route_map_set.metric + #define ROUTEMAP_METRIC_TYPE(E) (E)->route_map_set.metric_type ++#define ROUTEMAP_NEXTHOP(E) (E)->route_map_set.nexthop + }; + + #define OSPF_ASBR_CHECK_DELAY 30 +diff -Nur ./ospfd/ospf_lsa.c /tmp/quagga-0.99.20-patched/ospfd/ospf_lsa.c +--- ./ospfd/ospf_lsa.c 2011-09-29 16:59:32.000000000 +0400 ++++ /tmp/quagga-0.99.20-patched/ospfd/ospf_lsa.c 2012-01-15 18:44:18.000000000 +0400 +@@ -1614,7 +1614,8 @@ + stream_put_ospf_metric (s, mvalue); + + /* Get forwarding address to nexthop if on the Connection List, else 0. */ +- fwd_addr = ospf_external_lsa_nexthop_get (ospf, ei->nexthop); ++ fwd_addr = (ei->route_map_set.nexthop.s_addr != -1) ? ++ ROUTEMAP_NEXTHOP (ei) : ospf_external_lsa_nexthop_get (ospf, ei->nexthop); + + /* Put forwarding address. */ + stream_put_ipv4 (s, fwd_addr.s_addr); +diff -Nur ./ospfd/ospf_routemap.c /tmp/quagga-0.99.20-patched/ospfd/ospf_routemap.c +--- ./ospfd/ospf_routemap.c 2011-09-29 16:59:32.000000000 +0400 ++++ /tmp/quagga-0.99.20-patched/ospfd/ospf_routemap.c 2012-01-15 18:44:18.000000000 +0400 +@@ -527,6 +527,62 @@ + route_set_metric_type_free, + }; + ++/* `set ip next-hop IP_ADDRESS' */ ++/* Set nexthop to object. */ ++static route_map_result_t ++route_set_ip_nexthop (void *rule, struct prefix *prefix, ++ route_map_object_t type, void *object) ++{ ++ struct in_addr *address; ++ struct external_info *ei; ++ ++ if (type == RMAP_OSPF) ++ { ++ /* Fetch routemap's rule information. */ ++ address = rule; ++ ei = object; ++ ++ /* Set metric out value. */ ++ ei->route_map_set.nexthop = *address; ++ } ++ return RMAP_OKAY; ++} ++ ++/* set ip next-hop compilation. */ ++static void * ++route_set_ip_nexthop_compile (const char *arg) ++{ ++ struct in_addr *address = NULL; ++ int ret; ++ ++ address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr)); ++ ret = inet_aton (arg, address); ++ ++ if (ret == 0) ++ { ++ XFREE (MTYPE_ROUTE_MAP_COMPILED, address); ++ return NULL; ++ } ++ ++ return address; ++} ++ ++/* Free route map's compiled `set ip next-hop' value. */ ++static void ++route_set_ip_nexthop_free (void *rule) ++{ ++ XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); ++} ++ ++/* Set ip next-hop rule structure. */ ++struct route_map_rule_cmd route_set_ip_nexthop_cmd = ++{ ++ "ip next-hop", ++ route_set_ip_nexthop, ++ route_set_ip_nexthop_compile, ++ route_set_ip_nexthop_free, ++}; ++ + DEFUN (match_ip_nexthop, + match_ip_nexthop_cmd, + "match ip next-hop (<1-199>|<1300-2699>|WORD)", +@@ -781,6 +837,49 @@ + "OSPF[6] external type 1 metric\n" + "OSPF[6] external type 2 metric\n") + ++DEFUN (set_ip_nexthop, ++ set_ip_nexthop_cmd, ++ "set ip next-hop A.B.C.D", ++ SET_STR ++ IP_STR ++ "Next hop address\n" ++ "IP address of next hop\n") ++{ ++ union sockunion su; ++ int ret; ++ ++ ret = str2sockunion (argv[0], &su); ++ if (ret < 0) ++ { ++ vty_out (vty, "%% Malformed Next-hop address%s", VTY_NEWLINE); ++ return CMD_WARNING; ++ } ++ ++ return ospf_route_set_add (vty, vty->index, "ip next-hop", argv[0]); ++} ++ ++DEFUN (no_set_ip_nexthop, ++ no_set_ip_nexthop_cmd, ++ "no set ip next-hop", ++ NO_STR ++ SET_STR ++ "Next hop address\n") ++{ ++ if (argc == 0) ++ return ospf_route_set_delete (vty, vty->index, "ip next-hop", NULL); ++ ++ return ospf_route_set_delete (vty, vty->index, "ip next-hop", argv[0]); ++} ++ ++ALIAS (no_set_ip_nexthop, ++ no_set_ip_nexthop_val_cmd, ++ "no set ip next-hop A.B.C.D", ++ NO_STR ++ SET_STR ++ IP_STR ++ "Next hop address\n" ++ "IP address of next hop\n") ++ + /* Route-map init */ + void + ospf_route_map_init (void) +@@ -800,6 +899,7 @@ + + route_map_install_set (&route_set_metric_cmd); + route_map_install_set (&route_set_metric_type_cmd); ++ route_map_install_set (&route_set_ip_nexthop_cmd); + + install_element (RMAP_NODE, &match_ip_nexthop_cmd); + install_element (RMAP_NODE, &no_match_ip_nexthop_cmd); +@@ -823,4 +923,7 @@ + install_element (RMAP_NODE, &set_metric_type_cmd); + install_element (RMAP_NODE, &no_set_metric_type_cmd); + install_element (RMAP_NODE, &no_set_metric_type_val_cmd); ++ install_element (RMAP_NODE, &set_ip_nexthop_cmd); ++ install_element (RMAP_NODE, &no_set_ip_nexthop_cmd); ++ install_element (RMAP_NODE, &no_set_ip_nexthop_val_cmd); + }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211021306.qA2D6FOZ025881>