summaryrefslogtreecommitdiff
path: root/proto/ospf/lsupd.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2014-02-06 17:46:01 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2014-02-06 17:46:01 +0100
commit48e5f32db676645640f84ab3d630cce975aa6b20 (patch)
treeb940fc8156b3e0c18aab6c339a066bdb7a9ec1e0 /proto/ospf/lsupd.c
parentf48fa14214301382b2e6b134788a7506b61b664f (diff)
Many changes in I/O and OSPF sockets and packet handling.
I/O: - BSD: specify src addr on IP sockets by IP_HDRINCL - BSD: specify src addr on UDP sockets by IP_SENDSRCADDR - Linux: specify src addr on IP/UDP sockets by IP_PKTINFO - IPv6: specify src addr on IP/UDP sockets by IPV6_PKTINFO - Alternative SKF_BIND flag for binding to IP address - Allows IP/UDP sockets without tx_hook, on these sockets a packet is discarded when TX queue is full - Use consistently SOL_ for socket layer values. OSPF: - Packet src addr is always explicitly set - Support for secondary addresses in BSD - Dynamic RX/TX buffers - Fixes some minor buffer overruns - Interface option 'tx length' - Names for vlink pseudoifaces (vlinkX) - Vlinks use separate socket for TX - Vlinks do not use fixed associated iface - Fixes TTL for direct unicast packets - Fixes DONTROUTE for OSPF sockets - Use ifa->ifname instead of ifa->iface->name
Diffstat (limited to 'proto/ospf/lsupd.c')
-rw-r--r--proto/ospf/lsupd.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c
index beac6c83..1859867b 100644
--- a/proto/ospf/lsupd.c
+++ b/proto/ospf/lsupd.c
@@ -278,22 +278,22 @@ ospf_lsupd_flood(struct proto_ospf *po,
struct ospf_packet *op;
struct ospf_lsa_header *lh;
- pk = ospf_tx_buffer(ifa);
- op = &pk->ospf_packet;
-
- ospf_pkt_fill_hdr(ifa, pk, LSUPD_P);
- pk->lsano = htonl(1);
-
/* Check iface buffer size */
- int len2 = sizeof(struct ospf_lsupd_packet) + (hn ? ntohs(hn->length) : hh->length);
- if (len2 > ospf_pkt_bufsize(ifa))
+ uint len2 = sizeof(struct ospf_lsupd_packet) + (hn ? ntohs(hn->length) : hh->length);
+ if (ospf_iface_assure_bufsize(ifa, len2) < 0)
{
/* Cannot fit in a tx buffer, skip that iface */
log(L_ERR "OSPF: LSA too large to flood on %s (Type: %04x, Id: %R, Rt: %R)",
- ifa->iface->name, hh->type, hh->id, hh->rt);
+ ifa->ifname, hh->type, hh->id, hh->rt);
continue;
}
+ pk = ospf_tx_buffer(ifa);
+ op = &pk->ospf_packet;
+
+ ospf_pkt_fill_hdr(ifa, pk, LSUPD_P);
+ pk->lsano = htonl(1);
+
lh = (struct ospf_lsa_header *) (pk + 1);
/* Copy LSA into the packet */
@@ -322,7 +322,7 @@ ospf_lsupd_flood(struct proto_ospf *po,
op->length = htons(len);
- OSPF_PACKET(ospf_dump_lsupd, pk, "LSUPD packet flooded via %s", ifa->iface->name);
+ OSPF_PACKET(ospf_dump_lsupd, pk, "LSUPD packet flooded via %s", ifa->ifname);
switch (ifa->type)
{
@@ -406,7 +406,7 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
break;
/* LSA is larger than MTU, check buffer size */
- if (len2 > ospf_pkt_bufsize(n->ifa))
+ if (ospf_iface_assure_bufsize(n->ifa, len2) < 0)
{
/* Cannot fit in a tx buffer, skip that */
log(L_ERR "OSPF: LSA too large to send (Type: %04x, Id: %R, Rt: %R)",
@@ -414,6 +414,10 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
lsr = NODE_NEXT(lsr);
continue;
}
+
+ /* TX buffer could be reallocated */
+ pkt = ospf_tx_buffer(n->ifa);
+ buf = (void *) pkt;
}
/* Copy the LSA to the packet */
@@ -432,7 +436,7 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
pkt->lsano = htonl(lsano);
pkt->ospf_packet.length = htons(len);
OSPF_PACKET(ospf_dump_lsupd, pkt, "LSUPD packet sent to %I via %s",
- n->ip, n->ifa->iface->name);
+ n->ip, n->ifa->ifname);
ospf_send_to(n->ifa, n->ip);
}
}
@@ -455,7 +459,7 @@ ospf_lsupd_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
}
struct ospf_lsupd_packet *ps = (void *) ps_i;
- OSPF_PACKET(ospf_dump_lsupd, ps, "LSUPD packet received from %I via %s", n->ip, ifa->iface->name);
+ OSPF_PACKET(ospf_dump_lsupd, ps, "LSUPD packet received from %I via %s", n->ip, ifa->ifname);
if (n->state < NEIGHBOR_EXCHANGE)
{