[Click] ARP problem

Koen Segers koen.segers at edpnet.be
Wed Apr 5 10:02:31 EDT 2006


I have changed the arp elements from click-1.4.3 a bit, so that they work with 
my dynamicly generated ip. All that was needed was to change the static 
IPAddress to a pointer to the dynamic IPAddress.

Recently I added merging of manet's to my DDHCP protocol. This implies that 
some nodes reconfigure and get a new ip address.
The ARP elements become freaky now...

ARPQuerier crashes with a segmentation fault on the following rules of 
insert_entry (function is added as appendix):
		if (_age_tail)
				ae->age_pprev = &_age_tail->age_next;
			else
				ae->age_pprev = &_age_head;
			_age_tail = *ae->age_pprev = ae;

I tried to clear the arp table by calling clear_map but it gave the same 
problem. 

Can somebody explain me what's going on? And how I can overcome this problem?
I understand the meaning of ARP, but I can't figure out how this code works.


greetz




Appendix:
This is what I get from valgrind:
<snip>
00:03:47:70:89:05:      OLSRARPQuerier::there was no entry for 192.168.0.2
00:03:47:70:89:05:      OLSRARPQuerier::possible error
==32368== 
==32368== Conditional jump or move depends on uninitialised value(s)
==32368==    at 0x8258A94: 
Click::OLSRARPQuerier::insert_entry(Click::IPAddress const&, 
Click::EtherAddress const&) (olsr_arpquerier.cc:303)
==32368==    by 0x8257A9A: Click::AddARPEntry::simple_action(Click::Packet*) 
(packet.hh:655)
==32368==    by 0x81E6CFA: Click::Element::push(int, Click::Packet*) 
(element.cc:848)
==32368==    by 0x825CAF9: Click::OLSRClassifier::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x825C22B: Click::OLSRCheckPacketHeader::push(int, 
Click::Packet*) (element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x8241C01: Click::IPFilter::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
00:03:47:70:89:05:      OLSRARPQuerier::no error occured
link 192.168.0.1 <--> 192.168.0.2 insert | 31 161050
192.168.0.1 adding link to 192.168.0.2
Adding new neighbor: 192.168.0.2
No click upcall set!
00:03:47:70:89:04:      OLSRARPQuerier::there was no entry for 192.168.0.1
00:03:47:70:89:04:      OLSRARPQuerier::possible error
==32368== 
==32368== Use of uninitialised value of size 4
==32368==    at 0x8258AA5: 
Click::OLSRARPQuerier::insert_entry(Click::IPAddress const&, 
Click::EtherAddress const&) (olsr_arpquerier.cc:307)
==32368==    by 0x8257A9A: Click::AddARPEntry::simple_action(Click::Packet*) 
(packet.hh:655)
==32368==    by 0x81E6CFA: Click::Element::push(int, Click::Packet*) 
(element.cc:848)
==32368==    by 0x825CAF9: Click::OLSRClassifier::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x825C22B: Click::OLSRCheckPacketHeader::push(int, 
Click::Packet*) (element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x8241C01: Click::IPFilter::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368== 
==32368== Invalid write of size 4
==32368==    at 0x8258AA5: 
Click::OLSRARPQuerier::insert_entry(Click::IPAddress const&, 
Click::EtherAddress const&) (olsr_arpquerier.cc:307)
==32368==    by 0x8257A9A: Click::AddARPEntry::simple_action(Click::Packet*) 
(packet.hh:655)
==32368==    by 0x81E6CFA: Click::Element::push(int, Click::Packet*) 
(element.cc:848)
==32368==    by 0x825CAF9: Click::OLSRClassifier::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x825C22B: Click::OLSRCheckPacketHeader::push(int, 
Click::Packet*) (element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x8241C01: Click::IPFilter::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==  Address 0x59 is not stack'd, malloc'd or (recently) free'd
==32368== 
==32368== Process terminating with default action of signal 11 (SIGSEGV)
==32368==  Access not within mapped region at address 0x59
==32368==    at 0x8258AA5: 
Click::OLSRARPQuerier::insert_entry(Click::IPAddress const&, 
Click::EtherAddress const&) (olsr_arpquerier.cc:307)
==32368==    by 0x8257A9A: Click::AddARPEntry::simple_action(Click::Packet*) 
(packet.hh:655)
==32368==    by 0x81E6CFA: Click::Element::push(int, Click::Packet*) 
(element.cc:848)
==32368==    by 0x825CAF9: Click::OLSRClassifier::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x825C22B: Click::OLSRCheckPacketHeader::push(int, 
Click::Packet*) (element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x8241C01: Click::IPFilter::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)
==32368==    by 0x81E6D25: Click::Element::push(int, Click::Packet*) 
(element.hh:314)



void OLSRARPQuerier::insert_entry(const IPAddress &ip, const EtherAddress 
&ether)
{
	int bucket = ip_bucket(ip);
	//click_chatter("OLSRARPQuerier::insert_entry met ip %s en ethernet %s", 
ip.s().cc(), ether.s().cc());
		
	_lock.acquire_read();

	ARPEntry *ae = _map[bucket];

	while (ae && ae->ip != ip)
		ae = ae->next;

	if (ae)
	{
		//click_chatter("%s:\t:OLSRARPQuerier::there was allready an entry for %s", 
_info->get_hw_addr().s().cc(), ip.s().cc());
		if (ae->ok && ae->en != ether)
			click_chatter("OLSRARPQuerier overwriting an entry");
		ae->en = ether;
		ae->last_response_jiffies = click_jiffies();
		_lock.release_read();
	}
	else
	{
		click_chatter("%s:\tOLSRARPQuerier::there was no entry for %s", 
_info->get_hw_addr().s().cc(), ip.s().cc());
		_lock.release_read();
		_lock.acquire_write();
		if (_cache_size >= _capacity)
			expire_hook(0, this);
		if (ARPEntry *ae = new ARPEntry)
		{
			ae->ip = ip;
			ae->en = ether;
			ae->ok = 1;				// the entry is automatically ok, since we are setting the 
mac address
			ae->polling = 0;			// don't know what polling does ..
			ae->head = ae->tail = 0;		// no buffered packets
			ae->last_response_jiffies = click_jiffies();
			ae->pprev = &_map[bucket];
			if ((ae->next = _map[bucket]))
				ae->next->pprev = &ae->next;
			_map[bucket] = ae;

			click_chatter("%s:\tOLSRARPQuerier::possible error", 
_info->get_hw_addr().s().cc());
			if (_age_tail)
				ae->age_pprev = &_age_tail->age_next;
			else
				ae->age_pprev = &_age_head;
			_age_tail = *ae->age_pprev = ae;
			click_chatter("%s:\tOLSRARPQuerier::no error occured", 
_info->get_hw_addr().s().cc());
			ae->age_next = 0;
		}
		_lock.release_write();
	}
}


-- 

Koen Segers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : https://amsterdam.lcs.mit.edu/pipermail/click/attachments/20060405/2fdb582e/attachment-0001.pgp


More information about the click mailing list