OSPF is ready for changing MTU.
This commit is contained in:
parent
f158bb710b
commit
e7ef86a58c
5 changed files with 38 additions and 2 deletions
|
@ -45,6 +45,7 @@ sock *sk_new(pool *); /* Allocate new socket */
|
||||||
int sk_open(sock *); /* Open socket */
|
int sk_open(sock *); /* Open socket */
|
||||||
int sk_send(sock *, unsigned len); /* Send data, <0=err, >0=ok, 0=sleep */
|
int sk_send(sock *, unsigned len); /* Send data, <0=err, >0=ok, 0=sleep */
|
||||||
int sk_send_to(sock *, unsigned len, ip_addr to, unsigned port); /* sk_send to given destination */
|
int sk_send_to(sock *, unsigned len, ip_addr to, unsigned port); /* sk_send to given destination */
|
||||||
|
void sk_reallocate(sock *); /* Free and allocate tbuf & rbuf */
|
||||||
void sk_dump_all(void);
|
void sk_dump_all(void);
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
|
|
@ -119,6 +119,12 @@ ospf_dbdes_send(struct ospf_neighbor *n)
|
||||||
case NEIGHBOR_FULL:
|
case NEIGHBOR_FULL:
|
||||||
length = ntohs(((struct ospf_packet *)n)->length);
|
length = ntohs(((struct ospf_packet *)n)->length);
|
||||||
|
|
||||||
|
if(!length)
|
||||||
|
{
|
||||||
|
OSPF_TRACE(D_PACKETS, "No packet in my buffer for repeating");
|
||||||
|
ospf_neigh_sm(n, INM_KILLNBR);
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(ifa->ip_sk->tbuf, n->ldbdes, length);
|
memcpy(ifa->ip_sk->tbuf, n->ldbdes, length);
|
||||||
/* Copy last sent packet again */
|
/* Copy last sent packet again */
|
||||||
|
|
||||||
|
|
|
@ -430,8 +430,23 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface)
|
||||||
{
|
{
|
||||||
if((ifa=find_iface((struct proto_ospf *)p, iface))!=NULL)
|
if((ifa=find_iface((struct proto_ospf *)p, iface))!=NULL)
|
||||||
{
|
{
|
||||||
|
struct ospf_packet *op;
|
||||||
|
struct ospf_neighbor *n;
|
||||||
OSPF_TRACE(D_EVENTS, "Changing MTU on interface %s.", iface->name);
|
OSPF_TRACE(D_EVENTS, "Changing MTU on interface %s.", iface->name);
|
||||||
/* FIXME: change MTU */
|
sk_reallocate(ifa->hello_sk);
|
||||||
|
sk_reallocate(ifa->dr_sk);
|
||||||
|
sk_reallocate(ifa->ip_sk);
|
||||||
|
|
||||||
|
WALK_LIST(n,ifa->neigh_list)
|
||||||
|
{
|
||||||
|
op = (struct ospf_packet *)n->ldbdes;
|
||||||
|
n->ldbdes = mb_allocz(n->pool, iface->mtu);
|
||||||
|
|
||||||
|
if(ntohs(op->length) <= iface->mtu) /* If the packet in old buffer is bigger, let it filled by zeros */
|
||||||
|
memcpy(n->ldbdes, op, iface->mtu); /* If the packet is old is same or smaller, copy it */
|
||||||
|
|
||||||
|
rfree(op);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ ospf_neighbor_new(struct ospf_iface *ifa)
|
||||||
n->ifa = ifa;
|
n->ifa = ifa;
|
||||||
add_tail(&ifa->neigh_list, NODE n);
|
add_tail(&ifa->neigh_list, NODE n);
|
||||||
n->adj = 0;
|
n->adj = 0;
|
||||||
n->ldbdes=mb_alloc(pool, ifa->iface->mtu);
|
n->ldbdes=mb_allocz(pool, ifa->iface->mtu);
|
||||||
n->state=NEIGHBOR_DOWN;
|
n->state=NEIGHBOR_DOWN;
|
||||||
|
|
||||||
n->inactim = tm_new(pool);
|
n->inactim = tm_new(pool);
|
||||||
|
|
|
@ -599,6 +599,20 @@ sk_alloc_bufs(sock *s)
|
||||||
s->tpos = s->ttx = s->tbuf;
|
s->tpos = s->ttx = s->tbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sk_reallocate(sock *s)
|
||||||
|
{
|
||||||
|
if(!s) return;
|
||||||
|
|
||||||
|
if (s->rbuf_alloc)
|
||||||
|
xfree(s->rbuf_alloc);
|
||||||
|
s->rbuf = NULL;
|
||||||
|
if (s->tbuf_alloc)
|
||||||
|
xfree(s->tbuf_alloc);
|
||||||
|
s->tbuf = NULL;
|
||||||
|
sk_alloc_bufs(s);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sk_tcp_connected(sock *s)
|
sk_tcp_connected(sock *s)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue