From 9e7a548ce421660b0d22bfeb90c2b2b53742aac7 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 22 May 2012 14:32:22 +0200 Subject: build: allow configure and build in a separate directory Some .h files in lib/ are autogenerated. The search path should include the build directory and the source directory. They usually match but sometimes, they may be different. For example: $ mkdir build $ cd build $ ../configure $ make --- ospfd/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ospfd') diff --git a/ospfd/Makefile.am b/ospfd/Makefile.am index 2e4d5c8e..d0b4ae84 100644 --- a/ospfd/Makefile.am +++ b/ospfd/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in. -INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@ +INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib @SNMP_INCLUDES@ DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\" INSTALL_SDATA=@INSTALL@ -m 600 -- cgit v1.2.1 From 6b1e37f8537fa2a4560de32e83ca5089763e2d39 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 22 May 2012 22:15:20 +0200 Subject: build: only define HAVE_SNMP NetSNMP is the only SNMP implementation for Quagga. We don't need two different symbols. --- ospfd/ospf_snmp.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'ospfd') diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 9c9dd47a..739dcae1 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -25,14 +25,8 @@ #include #ifdef HAVE_SNMP -#ifdef HAVE_NETSNMP #include #include -#else -#include -#include -#include -#endif #include "if.h" #include "log.h" -- cgit v1.2.1 From 08d7f6533ecc0f935a76918c462982004534864d Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 22 May 2012 22:29:17 +0200 Subject: build: use net-snmp-config to configure NetSNMP The correct method to link to NetSNMP is to use net-snmp-config (which is like pkg-config). Explicit link to libcrypto is also dropped (NetSNMP libs are linked to libcrypto, no need to link Quagga to it). Moreover, @SNMP_INCLUDES@ is dropped because useless. Due to a bug in configure.ac, it was properly populated. --- ospfd/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ospfd') diff --git a/ospfd/Makefile.am b/ospfd/Makefile.am index d0b4ae84..f968d7d6 100644 --- a/ospfd/Makefile.am +++ b/ospfd/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in. -INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib @SNMP_INCLUDES@ +INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\" INSTALL_SDATA=@INSTALL@ -m 600 -- cgit v1.2.1 From 4b89e45d928d41bb5d32a00ba7b402d6a3bbdf44 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 24 May 2012 21:22:01 +0200 Subject: smux: remove `tick` argument from smux_trap() smux_trap() contains an argument whose use appears to be to set sysUpTime.0/timestamp field in SNMP trap. However, this value is not used in smux_trap(). Moreover, it is expected that this field is the value of sysUpTime.0 when the trap was sent and not any other time related to the trap. To avoid any confusion, we remove this field from the signature of the function. --- ospfd/ospf_snmp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ospfd') diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 739dcae1..409153b8 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -2616,7 +2616,7 @@ ospfTrapNbrStateChange (struct ospf_neighbor *on) index, IN_ADDR_SIZE + 1, ospfNbrTrapList, sizeof ospfNbrTrapList / sizeof (struct trap_object), - time (NULL), NBRSTATECHANGE); + NBRSTATECHANGE); } void @@ -2633,7 +2633,7 @@ ospfTrapVirtNbrStateChange (struct ospf_neighbor *on) index, IN_ADDR_SIZE + 1, ospfVirtNbrTrapList, sizeof ospfVirtNbrTrapList / sizeof (struct trap_object), - time (NULL), VIRTNBRSTATECHANGE); + VIRTNBRSTATECHANGE); } void @@ -2652,7 +2652,7 @@ ospfTrapIfStateChange (struct ospf_interface *oi) index, IN_ADDR_SIZE + 1, ospfIfTrapList, sizeof ospfIfTrapList / sizeof (struct trap_object), - time (NULL), IFSTATECHANGE); + IFSTATECHANGE); } void @@ -2669,7 +2669,7 @@ ospfTrapVirtIfStateChange (struct ospf_interface *oi) index, IN_ADDR_SIZE + 1, ospfVirtIfTrapList, sizeof ospfVirtIfTrapList / sizeof (struct trap_object), - time (NULL), VIRTIFSTATECHANGE); + VIRTIFSTATECHANGE); } /* Register OSPF2-MIB. */ void -- cgit v1.2.1 From b8cf46b715b2c21db5dce8118c70b4dd9b5255a3 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 25 May 2012 08:56:44 +0200 Subject: smux: drop findVar element from trap object struct This element was not unused. --- ospfd/ospf_snmp.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'ospfd') diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 409153b8..b2d56860 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -2568,35 +2568,35 @@ ospfAreaAggregateEntry (struct variable *v, oid *name, size_t *length, struct trap_object ospfNbrTrapList[] = { - {ospfGeneralGroup, -2, {1, OSPFROUTERID}}, - {ospfNbrEntry, 3, {10, 1, OSPFNBRIPADDR}}, - {ospfNbrEntry, 3, {10, 1, OSPFNBRRTRID}}, - {ospfNbrEntry, 3, {10, 1, OSPFNBRSTATE}} + {-2, {1, OSPFROUTERID}}, + {3, {10, 1, OSPFNBRIPADDR}}, + {3, {10, 1, OSPFNBRRTRID}}, + {3, {10, 1, OSPFNBRSTATE}} }; struct trap_object ospfVirtNbrTrapList[] = { - {ospfGeneralGroup, -2, {1, 1}}, - {ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRAREA}}, - {ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRRTRID}}, - {ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRSTATE}} + {-2, {1, 1}}, + {3, {11, 1, OSPFVIRTNBRAREA}}, + {3, {11, 1, OSPFVIRTNBRRTRID}}, + {3, {11, 1, OSPFVIRTNBRSTATE}} }; struct trap_object ospfIfTrapList[] = { - {ospfGeneralGroup, -2, {1, OSPFROUTERID}}, - {ospfIfEntry, 3, {7, 1, OSPFIFIPADDRESS}}, - {ospfIfEntry, 3, {7, 1, OSPFADDRESSLESSIF}}, - {ospfIfEntry, 3, {7, 1, OSPFIFSTATE}} + {-2, {1, OSPFROUTERID}}, + {3, {7, 1, OSPFIFIPADDRESS}}, + {3, {7, 1, OSPFADDRESSLESSIF}}, + {3, {7, 1, OSPFIFSTATE}} }; struct trap_object ospfVirtIfTrapList[] = { - {ospfGeneralGroup, -2, {1, OSPFROUTERID}}, - {ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFAREAID}}, - {ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFNEIGHBOR}}, - {ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFSTATE}} + {-2, {1, OSPFROUTERID}}, + {3, {9, 1, OSPFVIRTIFAREAID}}, + {3, {9, 1, OSPFVIRTIFNEIGHBOR}}, + {3, {9, 1, OSPFVIRTIFSTATE}} }; void -- cgit v1.2.1 From b7c0d0651cd64f644d02ef5e4d1b82febe7e57d8 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 25 May 2012 11:17:01 +0200 Subject: agentx: handle SNMP traps smux_trap() signature has been changed to provide appropriate level information to send SNMPv2 notifications. This includes the addition of the enterprise OID to use (from which is derived the SNMP trap OID) and the MIB registry to locate the appropriate function for variable bindings provided by the trap. The SMUX implementation has been updated but ignore the provided enterprise OID. Instead, it still uses the SMUX peer OID to keep compatibility with previous versions of Quagga. The SMUX implementation also ignores the provided MIB registry since it uses smux_get() function to grab the appropriate values. This is not possible with the AgentX implementation since there is no such function provided by NetSNMP. --- ospfd/ospf_snmp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'ospfd') diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index b2d56860..c8416de6 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -210,6 +210,7 @@ SNMP_LOCAL_VARIABLES /* OSPF-MIB instances. */ oid ospf_oid [] = { OSPF2MIB }; +oid ospf_trap_oid [] = { OSPF2MIB, 16, 2 }; /* Not reverse mappable! */ /* IP address 0.0.0.0. */ static struct in_addr ospf_empty_addr = {0}; @@ -2612,7 +2613,9 @@ ospfTrapNbrStateChange (struct ospf_neighbor *on) oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE); index[IN_ADDR_SIZE] = 0; - smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), + smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable), + ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid), + ospf_oid, sizeof ospf_oid / sizeof (oid), index, IN_ADDR_SIZE + 1, ospfNbrTrapList, sizeof ospfNbrTrapList / sizeof (struct trap_object), @@ -2629,7 +2632,9 @@ ospfTrapVirtNbrStateChange (struct ospf_neighbor *on) oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE); index[IN_ADDR_SIZE] = 0; - smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), + smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable), + ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid), + ospf_oid, sizeof ospf_oid / sizeof (oid), index, IN_ADDR_SIZE + 1, ospfVirtNbrTrapList, sizeof ospfVirtNbrTrapList / sizeof (struct trap_object), @@ -2648,7 +2653,9 @@ ospfTrapIfStateChange (struct ospf_interface *oi) oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE); index[IN_ADDR_SIZE] = 0; - smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), + smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable), + ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid), + ospf_oid, sizeof ospf_oid / sizeof (oid), index, IN_ADDR_SIZE + 1, ospfIfTrapList, sizeof ospfIfTrapList / sizeof (struct trap_object), @@ -2665,7 +2672,9 @@ ospfTrapVirtIfStateChange (struct ospf_interface *oi) oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE); index[IN_ADDR_SIZE] = 0; - smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), + smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable), + ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid), + ospf_oid, sizeof ospf_oid / sizeof (oid), index, IN_ADDR_SIZE + 1, ospfVirtIfTrapList, sizeof ospfVirtIfTrapList / sizeof (struct trap_object), -- cgit v1.2.1 From 8046ba6ec4d6e87bf8da6563c0f3e5e66c4652b3 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 31 May 2012 13:30:28 +0200 Subject: snmp: let handlers accept OID from a lesser prefix Most table handlers do not expect to be given an OID whose prefix is outside what they can handle. This is not a problem with the SMUX implementation since it always correct the OID such that the prefix matches. However, this is not the case for the AgentX implementation. A new function, smux_header_table() is used to do this normalization. --- ospfd/ospf_snmp.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'ospfd') diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index c8416de6..1daf0d6a 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -704,6 +704,10 @@ ospfAreaEntry (struct variable *v, oid *name, size_t *length, int exact, struct ospf_area *area; struct in_addr addr; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + memset (&addr, 0, sizeof (struct in_addr)); area = ospfAreaLookup (v, name, length, &addr, exact); @@ -847,6 +851,10 @@ ospfStubAreaEntry (struct variable *v, oid *name, size_t *length, struct ospf_area *area; struct in_addr addr; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + memset (&addr, 0, sizeof (struct in_addr)); area = ospfStubAreaLookup (v, name, length, &addr, exact); @@ -1078,6 +1086,10 @@ ospfLsdbEntry (struct variable *v, oid *name, size_t *length, int exact, struct in_addr router_id; struct ospf *ospf; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + /* INDEX { ospfLsdbAreaId, ospfLsdbType, ospfLsdbLsid, ospfLsdbRouterId } */ @@ -1240,6 +1252,10 @@ ospfAreaRangeEntry (struct variable *v, oid *name, size_t *length, int exact, struct in_addr mask; struct ospf *ospf; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + /* Check OSPF instance. */ ospf = ospf_lookup (); if (ospf == NULL) @@ -1344,6 +1360,10 @@ ospfHostEntry (struct variable *v, oid *name, size_t *length, int exact, struct in_addr addr; struct ospf *ospf; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + /* Check OSPF instance. */ ospf = ospf_lookup (); if (ospf == NULL) @@ -1679,6 +1699,10 @@ ospfIfEntry (struct variable *v, oid *name, size_t *length, int exact, struct ospf_interface *oi; struct ospf *ospf; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + ifindex = 0; memset (&ifaddr, 0, sizeof (struct in_addr)); @@ -1847,6 +1871,10 @@ ospfIfMetricEntry (struct variable *v, oid *name, size_t *length, int exact, struct ospf_interface *oi; struct ospf *ospf; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + ifindex = 0; memset (&ifaddr, 0, sizeof (struct in_addr)); @@ -2039,6 +2067,10 @@ ospfVirtIfEntry (struct variable *v, oid *name, size_t *length, int exact, struct in_addr area_id; struct in_addr neighbor; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + memset (&area_id, 0, sizeof (struct in_addr)); memset (&neighbor, 0, sizeof (struct in_addr)); @@ -2272,6 +2304,10 @@ ospfNbrEntry (struct variable *v, oid *name, size_t *length, int exact, struct ospf_neighbor *nbr; struct ospf_interface *oi; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + memset (&nbr_addr, 0, sizeof (struct in_addr)); ifindex = 0; @@ -2334,6 +2370,10 @@ ospfVirtNbrEntry (struct variable *v, oid *name, size_t *length, int exact, struct in_addr neighbor; struct ospf *ospf; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + memset (&area_id, 0, sizeof (struct in_addr)); memset (&neighbor, 0, sizeof (struct in_addr)); @@ -2482,6 +2522,10 @@ ospfExtLsdbEntry (struct variable *v, oid *name, size_t *length, int exact, struct in_addr router_id; struct ospf *ospf; + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + type = OSPF_AS_EXTERNAL_LSA; memset (&ls_id, 0, sizeof (struct in_addr)); memset (&router_id, 0, sizeof (struct in_addr)); @@ -2533,6 +2577,10 @@ static u_char * ospfAreaAggregateEntry (struct variable *v, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method) { + if (smux_header_table(v, name, length, exact, var_len, write_method) + == MATCH_FAILED) + return NULL; + /* Return the current value of the variable */ switch (v->magic) { -- cgit v1.2.1