summaryrefslogtreecommitdiff
path: root/proto/ospf/packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'proto/ospf/packet.c')
-rw-r--r--proto/ospf/packet.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c
index 6b6a97a4..38d7a75f 100644
--- a/proto/ospf/packet.c
+++ b/proto/ospf/packet.c
@@ -77,16 +77,16 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt, uint *plen)
reboot when system does not have independent RTC? */
if (!ifa->csn)
{
- ifa->csn = (u32) now;
- ifa->csn_use = now;
+ ifa->csn = (u32) (current_real_time() TO_S);
+ ifa->csn_use = current_time();
}
/* We must have sufficient delay between sending a packet and increasing
CSN to prevent reordering of packets (in a network) with different CSNs */
- if ((now - ifa->csn_use) > 1)
+ if ((current_time() - ifa->csn_use) > 1 S)
ifa->csn++;
- ifa->csn_use = now;
+ ifa->csn_use = current_time();
uint auth_len = mac_type_length(pass->alg);
byte *auth_tail = ((byte *) pkt + *plen);
@@ -203,7 +203,7 @@ drop:
/**
* ospf_rx_hook
* @sk: socket we received the packet.
- * @len: size of the packet
+ * @len: length of the packet
*
* This is the entry point for messages from neighbors. Many checks (like
* authentication, checksums, size) are done before the packet is passed to
@@ -231,7 +231,7 @@ ospf_rx_hook(sock *sk, uint len)
return 1;
int src_local, dst_local, dst_mcast;
- src_local = ipa_in_net(sk->faddr, ifa->addr->prefix, ifa->addr->pxlen);
+ src_local = ipa_in_netX(sk->faddr, &ifa->addr->prefix);
dst_local = ipa_equal(sk->laddr, ifa->addr->ip);
dst_mcast = ipa_equal(sk->laddr, ifa->all_routers) || ipa_equal(sk->laddr, ifa->des_routers);
@@ -270,9 +270,6 @@ ospf_rx_hook(sock *sk, uint len)
if (pkt == NULL)
DROP("bad IP header", len);
- if (ifa->check_ttl && (sk->rcv_ttl < 255))
- DROP("wrong TTL", sk->rcv_ttl);
-
if (len < sizeof(struct ospf_packet))
DROP("too short", len);
@@ -379,6 +376,10 @@ found:
if (ipa_equal(sk->laddr, ifa->des_routers) && (ifa->sk_dr == 0))
return 1;
+ /* TTL check must be done after instance dispatch */
+ if (ifa->check_ttl && (sk->rcv_ttl < 255))
+ DROP("wrong TTL", sk->rcv_ttl);
+
if (rid == p->router_id)
DROP1("my own router ID");
@@ -491,8 +492,8 @@ ospf_send_to_agt(struct ospf_iface *ifa, u8 state)
void
ospf_send_to_bdr(struct ospf_iface *ifa)
{
- if (ipa_nonzero(ifa->drip))
+ if (ipa_nonzero2(ifa->drip))
ospf_send_to(ifa, ifa->drip);
- if (ipa_nonzero(ifa->bdrip))
+ if (ipa_nonzero2(ifa->bdrip))
ospf_send_to(ifa, ifa->bdrip);
}