Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > c0394d3068b44395994f031447c8052d > files > 33

net-snmp-5.3.2.2-7.el5_4.2.src.rpm

433446: ipv6ScopeZoneTable produces errors to log

Written-By: Jan Safranek <jsafrane@redhat.com>
Reviewed-By: Radek Vokal <rvokal@redhat.com>

Create ipv6ScopeZoneEntry only for link-local addresses and only once
per interface.

Index: agent/mibgroup/ip-mib/data_access/ipv6scopezone_linux.c
===================================================================
--- agent/mibgroup/ip-mib/data_access/ipv6scopezone_linux.c	(revision 16827)
+++ agent/mibgroup/ip-mib/data_access/ipv6scopezone_linux.c	(working copy)
@@ -41,13 +41,25 @@
 }
 
 #if defined (INET6)
+
+/* scope identifiers, from kernel - include/net/ipv6.h */
+#define IPV6_ADDR_LOOPBACK      0x0010U
+#define IPV6_ADDR_LINKLOCAL     0x0020U
+#define IPV6_ADDR_SITELOCAL     0x0040U
+
 static int
 _scopezone_v6(netsnmp_container* container, int idx_offset)
 {
 
+    /*
+     * On Linux, we support only link-local scope zones.
+     * Each interface, which has link-local address, gets unique scope
+     * zone index.
+     */
     FILE           *in;
     char            line[80], addr[40];
     int             if_index, pfx_len, scope, flags, rc = 0;
+    int             last_if_index = -1;
     netsnmp_v6scopezone_entry *entry;
     static int      log_open_err = 1;
     
@@ -92,8 +104,23 @@
         DEBUGMSGTL(("access:scopezone:container",
                     "addr %s, index %d, pfx %d, scope %d, flags 0x%X\n",
                     addr, if_index, pfx_len, scope, flags));
-        /*
+
+        if (! (scope & IPV6_ADDR_LINKLOCAL)) {
+            DEBUGMSGTL(("access:scopezone:container", 
+                        "The address is not link-local, skipping\n"));
+            continue;
+        }
+        /* 
+         * Check that the interface was not inserted before, just in case
+         * one interface has two or more link-local addresses.
          */
+        if (last_if_index == if_index) {
+            DEBUGMSGTL(("access:scopezone:container", 
+                        "The interface was already inserted, skipping\n"));
+            continue;
+        }
+
+        last_if_index = if_index; 
         entry = netsnmp_access_scopezone_entry_create();
         if(NULL == entry) {
             rc = -3;