Skip to content

Commit

Permalink
ospf: Deal better with reloading ospf config files.
Browse files Browse the repository at this point in the history
Problem is this:  When loading a config file that has a new
interface, the route redistribution messages can come before
the new interface info is pushed.  That could lead to trying
to announce routes when the peer has a zero prefix.

This attempts to fix this by basically removing the assert.
I am hoping that the route redistribution will happen properly
when the peer comes up, but I'm not certain that is the case.
So, maybe more fixes coming..but at least we don't crash now.

Core was generated by `xorp_ospfv2'.
Program terminated with signal 6, Aborted.
(gdb) bt
    at libxorp/xlog.c:480
    a3=0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>, a4=140733526888592) at ./libxorp/callback_nodebug.hh:8966

Signed-off-by: Ben Greear <greearb@candelatech.com>
  • Loading branch information
greearb committed Apr 22, 2011
1 parent 1c0ae64 commit 323cbc6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions xorp/libfeaclient/ifmgr_atoms.cc
Expand Up @@ -43,9 +43,9 @@ IfMgrIfTree::find_interface(const string& ifname) const

/* Print this thing out for debugging purposes. */
string
IfMgrIfTree::toString() {
IfMgrIfTree::toString() const {
ostringstream oss;
IfMgrIfTree::IfMap::iterator ii = interfaces().begin();
IfMgrIfTree::IfMap::const_iterator ii = interfaces().begin();
while (ii != interfaces().end()) {
oss << ii->second.toString() << endl;
ii++;
Expand Down
2 changes: 1 addition & 1 deletion xorp/libfeaclient/ifmgr_atoms.hh
Expand Up @@ -254,7 +254,7 @@ public:
string& vifname) const;

/* Print this thing out for debugging purposes. */
string toString();
string toString() const;

protected:
IfMap _interfaces; // The interface configuration state
Expand Down
13 changes: 5 additions & 8 deletions xorp/ospf/peer.cc
Expand Up @@ -162,16 +162,12 @@ PeerOut<A>::set_mask(Peer<A> *peer)
template <typename A>
uint16_t
PeerOut<A>::get_interface_prefix_length() const {
if (0 != _interface_prefix_length || VLINK == _interface) {
return _interface_prefix_length;
}
else {
if (!(0 != _interface_prefix_length || VLINK == _interface)) {
XLOG_WARNING("ERROR: PeerOut: %s/%s has bad prefix: %i address: %s\n",
_interface.c_str(), _vif.c_str(),
_interface_prefix_length, _interface_address.str().c_str());
XLOG_ASSERT(0 != _interface_prefix_length || VLINK == _interface);
return 0;
}
return _interface_prefix_length;
}

template <typename A>
Expand Down Expand Up @@ -562,6 +558,7 @@ PeerOut<A>::bring_up_peering()

// Get the prefix length.
A source = get_interface_address();
// This is effectively this->set_prefix_length, as it's pass-by-reference.
if (!_ospf.get_prefix_length(_interface, _vif, source,
_interface_prefix_length)) {
XLOG_ERROR("Unable to get prefix length for %s/%s/%s",
Expand Down Expand Up @@ -1190,8 +1187,8 @@ Peer<A>::receive(A dst, A src, Packet *packet)
switch(_ospf.get_version()) {
case OspfTypes::V2: {
const uint16_t plen = get_interface_prefix_length();
if (IPNet<A>(get_interface_address(), plen) !=
IPNet<A>(src, plen)) {
if ((plen == 0) ||
(IPNet<A>(get_interface_address(), plen) != IPNet<A>(src, plen))) {
XLOG_TRACE(_ospf.trace()._input_errors,
"Dropping packet from foreign network %s\n",
cstring(IPNet<A>(src, plen)));
Expand Down
10 changes: 6 additions & 4 deletions xorp/ospf/peer_manager.cc
Expand Up @@ -999,10 +999,12 @@ PeerManager<A>::configured_network(const A address) const
{
typename map<OspfTypes::PeerID, PeerOut<A> *>::const_iterator i;
for(i = _peers.begin(); i != _peers.end(); i++) {
IPNet<A> net((*i).second->get_interface_address(),
(*i).second->get_interface_prefix_length());
if (net.contains(address))
return true;
if ((*i).second->get_interface_prefix_length() != 0) {
IPNet<A> net((*i).second->get_interface_address(),
(*i).second->get_interface_prefix_length());
if (net.contains(address))
return true;
}
}

return false;
Expand Down
1 change: 1 addition & 0 deletions xorp/ospf/xrl_io.cc
Expand Up @@ -949,6 +949,7 @@ XrlIO<IPv4>::updates_made()
const IfMgrIPv4Atom* other_addr_atom;

XLOG_WARNING("XrlIO<IPv4>::updates_made, _iftree:\n%s", _iftree.toString().c_str());
XLOG_WARNING("XrlIO<IPv4>::updates_made, ifmgr_iftree:\n%s", ifmgr_iftree().toString().c_str());

//
// Check whether the old interfaces, vifs and addresses are still there
Expand Down

0 comments on commit 323cbc6

Please sign in to comment.