summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
Diffstat (limited to 'proto')
-rw-r--r--proto/bfd/packets.c8
-rw-r--r--proto/ospf/iface.c2
-rw-r--r--proto/ospf/lsalib.c2
-rw-r--r--proto/ospf/ospf.h9
-rw-r--r--proto/ospf/rt.c31
-rw-r--r--proto/radv/packets.c1
-rw-r--r--proto/rip/packets.c1
7 files changed, 30 insertions, 24 deletions
diff --git a/proto/bfd/packets.c b/proto/bfd/packets.c
index cb40bcda..2200acfa 100644
--- a/proto/bfd/packets.c
+++ b/proto/bfd/packets.c
@@ -202,9 +202,7 @@ bfd_open_rx_sk(struct bfd_proto *p, int multihop)
sk->priority = sk_priority_control;
sk->flags = SKF_THREAD | SKF_LADDR_RX | (!multihop ? SKF_TTL_RX : 0);
-#ifdef IPV6
- sk->flags |= SKF_V6ONLY;
-#endif
+ sk->af = AF_INET6;
if (sk_open(sk) < 0)
goto err;
@@ -237,9 +235,7 @@ bfd_open_tx_sk(struct bfd_proto *p, ip_addr local, struct iface *ifa)
sk->ttl = ifa ? 255 : -1;
sk->flags = SKF_THREAD | SKF_BIND | SKF_HIGH_PORT;
-#ifdef IPV6
- sk->flags |= SKF_V6ONLY;
-#endif
+ sk->af = AF_INET6;
if (sk_open(sk) < 0)
goto err;
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c
index 5d37b005..91e22266 100644
--- a/proto/ospf/iface.c
+++ b/proto/ospf/iface.c
@@ -111,6 +111,7 @@ ospf_sk_open(struct ospf_iface *ifa)
sk->dport = OSPF_PROTO;
sk->saddr = ifa->addr->ip;
sk->iface = ifa->iface;
+ sk->af = ospf_is_v2(p) ? AF_INET : AF_INET6;
sk->tos = ifa->cf->tx_tos;
sk->priority = ifa->cf->tx_priority;
@@ -193,6 +194,7 @@ ospf_open_vlink_sk(struct ospf_proto *p)
sock *sk = sk_new(p->p.pool);
sk->type = SK_IP;
sk->dport = OSPF_PROTO;
+ sk->af = ospf_is_v2(p) ? AF_INET : AF_INET6;
/* FIXME: configurable tos/priority ? */
sk->tos = IP_PREC_INTERNET_CONTROL;
diff --git a/proto/ospf/lsalib.c b/proto/ospf/lsalib.c
index 9a6b0457..5564bee7 100644
--- a/proto/ospf/lsalib.c
+++ b/proto/ospf/lsalib.c
@@ -493,7 +493,7 @@ lsa_validate_ext3(struct ospf_lsa_header *lsa, struct ospf_lsa_ext3 *body)
return 0;
int len = IPV6_PREFIX_SPACE(pxl);
- if (body->metric & LSA_EXT3_FBIT) // forwardinf address
+ if (body->metric & LSA_EXT3_FBIT) // forwarding address
len += 16;
if (body->metric & LSA_EXT3_TBIT) // route tag
len += 4;
diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h
index 6291ae1a..3e96b511 100644
--- a/proto/ospf/ospf.h
+++ b/proto/ospf/ospf.h
@@ -726,9 +726,16 @@ lsa_net_count(struct ospf_lsa_header *lsa)
#define IPV6_PREFIX_SPACE(x) ((((x) + 63) / 32) * 4)
#define IPV6_PREFIX_WORDS(x) (((x) + 63) / 32)
-/* FIXME: these four functions should be significantly redesigned w.r.t. integration,
+/* FIXME: these functions should be significantly redesigned w.r.t. integration,
also should be named as ospf3_* instead of *_ipv6_* */
+static inline int
+ospf_valid_prefix(net_addr *n)
+{
+ /* In OSPFv2, prefix is stored as netmask; ip4_masklen() returns 255 for invalid one */
+ return n->pxlen <= IP6_MAX_PREFIX_LENGTH;
+}
+
static inline u32 *
ospf_get_ipv6_prefix(u32 *buf, net_addr *N, u8 *pxopts, u16 *rest)
{
diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c
index aee0368a..0adc3871 100644
--- a/proto/ospf/rt.c
+++ b/proto/ospf/rt.c
@@ -412,7 +412,7 @@ add_network(struct ospf_area *oa, net_addr *net, int metric, struct top_hash_ent
.nhs = en->nhs
};
- if (net->pxlen > MAX_PREFIX_LENGTH)
+ if (!ospf_valid_prefix(net))
{
log(L_WARN "%s: Invalid prefix in LSA (Type: %04x, Id: %R, Rt: %R)",
p->p.name, en->lsa_type, en->lsa.id, en->lsa.rt);
@@ -765,16 +765,16 @@ ospf_rt_sum(struct ospf_area *oa)
{
lsa_parse_sum_net(en, ospf_is_v2(p), &net, &pxopts, &metric);
- if (pxopts & OPT_PX_NU)
- continue;
-
- if (net.pxlen > MAX_PREFIX_LENGTH)
+ if (!ospf_valid_prefix(&net))
{
log(L_WARN "%s: Invalid prefix in LSA (Type: %04x, Id: %R, Rt: %R)",
p->p.name, en->lsa_type, en->lsa.id, en->lsa.rt);
continue;
}
+ if (pxopts & OPT_PX_NU)
+ continue;
+
options = 0;
type = ORT_NET;
}
@@ -862,16 +862,16 @@ ospf_rt_sum_tr(struct ospf_area *oa)
lsa_parse_sum_net(en, ospf_is_v2(p), &net, &pxopts, &metric);
- if (pxopts & OPT_PX_NU)
- continue;
-
- if (net.pxlen > MAX_PREFIX_LENGTH)
+ if (!ospf_valid_prefix(&net))
{
log(L_WARN "%s: Invalid prefix in LSA (Type: %04x, Id: %R, Rt: %R)",
p->p.name, en->lsa_type, en->lsa.id, en->lsa.rt);
continue;
}
+ if (pxopts & OPT_PX_NU)
+ continue;
+
re = fib_find(&p->rtf, &net);
}
else // en->lsa_type == LSA_T_SUM_RT
@@ -1466,19 +1466,18 @@ ospf_ext_spf(struct ospf_proto *p)
lsa_parse_ext(en, ospf_is_v2(p), &rt);
- if (rt.metric == LSINFINITY)
- continue;
-
- if (rt.pxopts & OPT_PX_NU)
- continue;
-
- if (rt.net.pxlen > MAX_PREFIX_LENGTH)
+ if (!ospf_valid_prefix(&rt.net))
{
log(L_WARN "%s: Invalid prefix in LSA (Type: %04x, Id: %R, Rt: %R)",
p->p.name, en->lsa_type, en->lsa.id, en->lsa.rt);
continue;
}
+ if (rt.metric == LSINFINITY)
+ continue;
+
+ if (rt.pxopts & OPT_PX_NU)
+ continue;
/* 16.4. (3) */
/* If there are more areas, we already precomputed preferred ASBR
diff --git a/proto/radv/packets.c b/proto/radv/packets.c
index a38b58b2..3bb38221 100644
--- a/proto/radv/packets.c
+++ b/proto/radv/packets.c
@@ -412,6 +412,7 @@ radv_sk_open(struct radv_iface *ifa)
sk->type = SK_IP;
sk->dport = ICMPV6_PROTO;
sk->saddr = ifa->addr->ip;
+ sk->af = AF_INET6;
sk->ttl = 255; /* Mandatory for Neighbor Discovery packets */
sk->rx_hook = radv_rx_hook;
diff --git a/proto/rip/packets.c b/proto/rip/packets.c
index 4fc832d5..85f0bea5 100644
--- a/proto/rip/packets.c
+++ b/proto/rip/packets.c
@@ -715,6 +715,7 @@ rip_open_socket(struct rip_iface *ifa)
sock *sk = sk_new(p->p.pool);
sk->type = SK_UDP;
+ sk->af = rip_is_v2(p) ? AF_INET : AF_INET6;
sk->sport = ifa->cf->port;
sk->dport = ifa->cf->port;
sk->iface = ifa->iface;