Skip to content

Commit

Permalink
Send proxied NA to the correct destination address
Browse files Browse the repository at this point in the history
We need to send the NA back to the All Nodes Multicast address
rather than attempting to route to "::".

Signed-off-by: Scott Parlane <[email protected]>
  • Loading branch information
blairsteven authored and sparlane committed Sep 21, 2016
1 parent 8afd356 commit cf244c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/iface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include <linux/filter.h>

#include <errno.h>
#include <string>
#include <vector>
#include <map>
Expand Down Expand Up @@ -341,7 +342,11 @@ ssize_t iface::write(int fd, const address& daddr, const uint8_t* msg, size_t si
int len;

if ((len = sendmsg(fd,& mhdr, 0)) < 0)
{
int e = errno;
logger::error() << "iface::write() failed! errno=" << e;
return -1;
}

return len;
}
Expand Down Expand Up @@ -427,7 +432,7 @@ ssize_t iface::write_advert(const address& daddr, const address& taddr, bool rou
opt->nd_opt_len = 1;

na->nd_na_type = ND_NEIGHBOR_ADVERT;
na->nd_na_flags_reserved = ND_NA_FLAG_SOLICITED | (router ? ND_NA_FLAG_ROUTER : 0);
na->nd_na_flags_reserved = (daddr.is_multicast() ? 0 : ND_NA_FLAG_SOLICITED) | (router ? ND_NA_FLAG_ROUTER : 0);

memcpy(&na->nd_na_target,& taddr.const_addr(), sizeof(struct in6_addr));

Expand Down
4 changes: 3 additions & 1 deletion src/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ NDPPD_NS_BEGIN

std::list<weak_ptr<session> > session::_sessions;

static address all_nodes = address("ff02::1");

void session::update_all(int elapsed_time)
{
for (std::list<weak_ptr<session> >::iterator it = _sessions.begin();
Expand Down Expand Up @@ -69,7 +71,7 @@ ptr<session> session::create(const ptr<proxy>& pr, const address& saddr,

se->_ptr = se;
se->_pr = pr;
se->_saddr = saddr;
se->_saddr = address("::") == saddr ? all_nodes : saddr;
se->_taddr = taddr;
se->_daddr = daddr;
se->_ttl = pr->timeout();
Expand Down

0 comments on commit cf244c1

Please sign in to comment.