bug-zebra
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

minor bug-fixes to ospf_snmp.c


From: Arnold, Gilad
Subject: minor bug-fixes to ospf_snmp.c
Date: Tue, 29 Jan 2002 15:25:10 +0200

Hi,

The following patch fixes several issues in ospfd_snmp.c (hopefully I'm
right
about the diagnosis...):

1. Return correct value ("advertise" or "don't advertise") for
   ospfAreaRangeEffect.

2. Return correct authentication type for ospfIfAuthType and
   ospfVirtIfAuthType: If authentication is set for the interface then
return
   it, otherwise return the area's authentication type.

3. Fix ospfIfMetricXXX entry selection, namely correct usage of the
   ospfIfMetricTOS index (currently enabled TOS=0 only). Also, fix
   ospfIfMetricValue to return the actual interface cost (why return a
   constant value of "1"?).

4. Add a sanity check for non-null ospf_top, thus preveinting segmentation
   faults in two cases.


Patch included for CVS version as of 2002-01-29.

G.

---


Index: ospfd/ospf_snmp.c
===================================================================
RCS file: /cvsroot/zebra/ospfd/ospf_snmp.c,v
retrieving revision 1.27
diff -c -r1.27 ospf_snmp.c
*** ospfd/ospf_snmp.c   30 Aug 2001 00:53:11 -0000      1.27
--- ospfd/ospf_snmp.c   29 Jan 2002 10:05:44 -0000
***************
*** 1237,1243 ****
      case OSPFAREARANGEEFFECT: /* 5 */
  #define OSPF_advertiseMatching      1
  #define OSPF_doNotAdvertiseMatching 2
!       return SNMP_INTEGER (OSPF_advertiseMatching);
        break;
      default:
        return NULL;
--- 1237,1246 ----
      case OSPFAREARANGEEFFECT: /* 5 */
  #define OSPF_advertiseMatching      1
  #define OSPF_doNotAdvertiseMatching 2
!       if (CHECK_FLAG (range->flags, OSPF_RANGE_SUPPRESS))
!       return SNMP_INTEGER (OSPF_doNotAdvertiseMatching);
!       else
!       return SNMP_INTEGER (OSPF_advertiseMatching);
        break;
      default:
        return NULL;
***************
*** 1594,1599 ****
--- 1597,1603 ----
    unsigned int ifindex;
    struct in_addr ifaddr;
    struct ospf_interface *oi;
+   int auth_type;
  
    ifindex = 0;
    memset (&ifaddr, 0, sizeof (struct in_addr));
***************
*** 1681,1690 ****
        return SNMP_INTEGER (SNMP_FALSE);
        break;
      case OSPFIFAUTHTYPE:      /* 20 */
!       if (oi->area)
!       return SNMP_INTEGER (oi->area->auth_type);
!       else
!       return SNMP_INTEGER (0);
        break;
      default:
        return NULL;
--- 1685,1699 ----
        return SNMP_INTEGER (SNMP_FALSE);
        break;
      case OSPFIFAUTHTYPE:      /* 20 */
!       auth_type = OSPF_IF_PARAM (oi, auth_type);
!       if (auth_type == OSPF_AUTH_NOTSET)
!       {
!         if (oi->area)
!           auth_type = oi->area->auth_type;
!         else
!           auth_type = OSPF_AUTH_NULL;
!       }
!       return SNMP_INTEGER (auth_type);
        break;
      default:
        return NULL;
***************
*** 1693,1700 ****
    return NULL;
  }
  
- #define OSPF_SNMP_METRIC_VALUE 1
- 
  struct interface *
  ospfIfMetricLookup (struct variable *v, oid *name, size_t *length,
                    struct in_addr *ifaddr, unsigned int *ifindex, int
exact)
--- 1702,1707 ----
***************
*** 1704,1710 ****
    int ifindex_next = 0;
    struct interface *ifp;
    oid *offset;
!   int metric;
  
    if (exact)
      {
--- 1711,1717 ----
    int ifindex_next = 0;
    struct interface *ifp;
    oid *offset;
!   int tos;
  
    if (exact)
      {
***************
*** 1713,1721 ****
  
        oid2in_addr (name + v->namelen, IN_ADDR_SIZE, ifaddr);
        *ifindex = name[v->namelen + IN_ADDR_SIZE];
!       metric = name[v->namelen + IN_ADDR_SIZE + 1];
  
!       if (metric != OSPF_SNMP_METRIC_VALUE)
        return NULL;
  
        return ospf_snmp_if_lookup (ifaddr, ifindex);
--- 1720,1728 ----
  
        oid2in_addr (name + v->namelen, IN_ADDR_SIZE, ifaddr);
        *ifindex = name[v->namelen + IN_ADDR_SIZE];
!       tos = name[v->namelen + IN_ADDR_SIZE + 1];
  
!       if (tos != 0)
        return NULL;
  
        return ospf_snmp_if_lookup (ifaddr, ifindex);
***************
*** 1749,1755 ****
          offset += IN_ADDR_SIZE;
          *offset = *ifindex;
          offset++;
!         *offset = OSPF_SNMP_METRIC_VALUE;
          return ifp;
        }
      }
--- 1756,1762 ----
          offset += IN_ADDR_SIZE;
          *offset = *ifindex;
          offset++;
!         *offset = 0;
          return ifp;
        }
      }
***************
*** 1794,1800 ****
        return SNMP_INTEGER (0);
        break;
      case OSPFIFMETRICVALUE:
!       return SNMP_INTEGER (OSPF_SNMP_METRIC_VALUE);
        break;
      case OSPFIFMETRICSTATUS:
        return SNMP_INTEGER (1);
--- 1801,1807 ----
        return SNMP_INTEGER (0);
        break;
      case OSPFIFMETRICVALUE:
!       return SNMP_INTEGER (oi->output_cost);
        break;
      case OSPFIFMETRICSTATUS:
        return SNMP_INTEGER (1);
***************
*** 1960,1965 ****
--- 1967,1976 ----
    struct ospf_interface *oi;
    struct in_addr area_id;
    struct in_addr neighbor;
+   int auth_type;
+ 
+   if (! ospf_top)
+     return NULL;
  
    memset (&area_id, 0, sizeof (struct in_addr));
    memset (&neighbor, 0, sizeof (struct in_addr));
***************
*** 2006,2015 ****
        return SNMP_INTEGER (SNMP_VALID);
        break;
      case OSPFVIRTIFAUTHTYPE:
!       if (oi->area)
!       return SNMP_INTEGER (oi->area->auth_type);
!       else
!       return SNMP_INTEGER (0);
        break;
      default:
        return NULL;
--- 2017,2031 ----
        return SNMP_INTEGER (SNMP_VALID);
        break;
      case OSPFVIRTIFAUTHTYPE:
!       auth_type = OSPF_IF_PARAM (oi, auth_type);
!       if (auth_type == OSPF_AUTH_NOTSET)
!       {
!         if (oi->area)
!           auth_type = oi->area->auth_type;
!         else
!           auth_type = OSPF_AUTH_NULL;
!       }
!       return SNMP_INTEGER (auth_type);
        break;
      default:
        return NULL;
***************
*** 2143,2148 ****
--- 2159,2167 ----
    unsigned int ifindex;
    struct ospf_neighbor *nbr;
    struct ospf_interface *oi;
+ 
+   if (! ospf_top)
+     return NULL;
  
    memset (&nbr_addr, 0, sizeof (struct in_addr));
    ifindex = 0;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]