CDP/LLDP neighbor matching fails when multiple ports match the identification

Bug #1447973 reported by Morten Brekkevold
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Network Administration Visualized
Fix Released
High
Morten Brekkevold

Bug Description

A customer reports the topo job consistently failing for one of their switches. A huge traceback reveals that as ipdevpoll attempts to match a CDP record to a neighboring port, multiple Interface objects are returned. The code doesn't expect this, and crashes.

With some added debug logging, it appears the CDP record in question uses the neighboring port's ifalias value as its identification. The neighboring switch, unfortunately, has four ports with this same ifalias value, causing the code to glitch.

Multiple matches should be treated equivalent to no match, and should probably be logged too.

Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :

The traceback looks like this:

2015-04-24 09:53:28,554 [ERROR jobs.jobhandler] [topo example-sw.example.org] Plugin nav.ipdevpoll.plugins.cdp.CDP(u'example-sw.example.org') reported an unhandled failure
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 397, in errback
    self._startRunCallbacks(fail)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 464, in _startRunCallbacks
    self._runCallbacks()
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 551, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1101, in gotResult
    _inlineCallbacks(r, g, deferred)
--- <exception caught here> ---
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1043, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/lib/python2.7/dist-packages/twisted/python/failure.py", line 382, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/plugins/cdp.py", line 64, in handle
    yield run_in_thread(self._process_cache)
  File "/usr/lib/python2.7/dist-packages/twisted/python/threadpool.py", line 207, in _worker
    result = context.call(ctx, function, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/db.py", line 152, in _reset
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/db.py", line 111, in _autocommit
    result = func(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/plugins/cdp.py", line 82, in _process_cache
    neighbors = [CDPNeighbor(cdp, self.netbox.ip) for cdp in self.cache]
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/neighbor.py", line 115, in __init__
    self.identify()
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/neighbor.py", line 119, in identify
    self.interface = self._identify_interface()
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/neighbor.py", line 257, in _identify_interface
    return self._interface_from_name(self.record.deviceport)
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/neighbor.py", line 218, in _interface_from_name
    ifc = self._interface_query(netbox & query)
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/neighbor.py", line 227, in _interface_query
    'id', 'ifname', 'ifdescr', 'iftype').get(netbox & query)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 368, in get
    % (self.model._meta.object_name, num, kwargs))
nav.models.manage.MultipleObjectsReturned: get() returned more than one Interface -- it returned 4! Lookup parameters were {}

Changed in nav:
status: Confirmed → In Progress
Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :
Changed in nav:
status: In Progress → Fix Committed
description: updated
Changed in nav:
milestone: 4.2.7 → 4.3.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.