Added automatic renewal of active sessions (what determines if its active can be improved in future)

This commit is contained in:
John Sharratt 2017-07-01 11:31:50 +02:00
parent 7e0948bf96
commit f8ea51ab5e
4 changed files with 39 additions and 4 deletions

View File

@ -588,7 +588,7 @@ int iface::poll_all()
const ptr<session> sess = *s_it;
if ((sess->taddr() == taddr) && (sess->status() == session::WAITING)) {
if ((sess->taddr() == taddr) && (sess->status() == session::WAITING || sess->status() == session::RENEWING)) {
sess->handle_advert(ifa);
break;
}

View File

@ -73,6 +73,8 @@ void proxy::handle_solicit(const address& saddr, const address& daddr,
for (std::list<ptr<session> >::iterator sit = _sessions.begin();
sit != _sessions.end(); sit++) {
(*sit)->touch();
if ((*sit)->taddr() == taddr) {
switch ((*sit)->status()) {
case session::WAITING:
@ -80,6 +82,7 @@ void proxy::handle_solicit(const address& saddr, const address& daddr,
break;
case session::VALID:
case session::RENEWING:
(*sit)->send_advert();
}

View File

@ -49,6 +49,20 @@ void session::update_all(int elapsed_time)
se->_ttl = se->_pr->deadtime();
break;
case session::VALID:
if (se->_touched == true) {
logger::debug() << "session is renewing";
se->_status = session::RENEWING;
se->_ttl = se->_pr->timeout();
se->_touched = false;
// Send another solicit to make sure the route is still valid
se->send_solicit();
} else {
se->_pr->remove_session(se);
}
break;
default:
se->_pr->remove_session(se);
}
@ -82,6 +96,7 @@ ptr<session> session::create(const ptr<proxy>& pr, const address& saddr,
se->_daddr = daddr;
se->_autowire = auto_wire;
se->_ttl = pr->timeout();
se->_touched = true;
_sessions.push_back(se);
@ -112,6 +127,11 @@ void session::send_solicit()
}
}
void session::touch()
{
_touched = true;
}
void session::send_advert()
{
_pr->ifa()->write_advert(_saddr, _taddr, _pr->router());
@ -197,6 +217,11 @@ bool session::autowire() const
return _autowire;
}
bool session::touched() const
{
return _touched;
}
int session::status() const
{
return _status;

View File

@ -34,6 +34,8 @@ private:
bool _autowire;
bool _touched;
// An array of interfaces this session is monitoring for
// ND_NEIGHBOR_ADVERT on.
std::list<ptr<iface> > _ifaces;
@ -50,6 +52,7 @@ public:
enum
{
WAITING, // Waiting for an advert response.
RENEWING, // Renewing;
VALID, // Valid;
INVALID // Invalid;
};
@ -72,6 +75,8 @@ public:
bool autowire() const;
bool touched() const;
int status() const;
void status(int val);
@ -84,6 +89,8 @@ public:
void handle_auto_unwire(const ptr<iface>& ifa);
void touch();
void send_advert();
void send_solicit();