-/* $OpenBSD: mpls_input.c,v 1.62 2017/12/08 21:52:49 claudio Exp $ */
+/* $OpenBSD: mpls_input.c,v 1.63 2017/12/08 21:56:22 claudio Exp $ */
/*
* Copyright (c) 2008 Claudio Jeker <claudio@openbsd.org>
#define MPLS_TTL_GET(l) (ntohl((l) & MPLS_TTL_MASK))
#endif
-int mpls_ip_adjttl(struct mbuf *, u_int8_t);
+struct mbuf *mpls_ip_adjttl(struct mbuf *, u_int8_t);
#ifdef INET6
-int mpls_ip6_adjttl(struct mbuf *, u_int8_t);
+struct mbuf *mpls_ip6_adjttl(struct mbuf *, u_int8_t);
#endif
struct mbuf *mpls_do_error(struct mbuf *, int, int, int);
switch (ntohl(smpls->smpls_label)) {
case MPLS_LABEL_IPV4NULL:
do_v4:
- if (mpls_ip_adjttl(m, ttl)) {
+ if ((m = mpls_ip_adjttl(m, ttl)) == NULL) {
if_put(ifp);
return;
}
#ifdef INET6
case MPLS_LABEL_IPV6NULL:
do_v6:
- if (mpls_ip6_adjttl(m, ttl)) {
+ if ((m = mpls_ip6_adjttl(m, ttl)) == NULL) {
if_put(ifp);
return;
}
switch(rt->rt_gateway->sa_family) {
case AF_INET:
- if (mpls_ip_adjttl(m, ttl))
+ if ((m = mpls_ip_adjttl(m, ttl)) == NULL)
goto done;
break;
#ifdef INET6
case AF_INET6:
- if (mpls_ip6_adjttl(m, ttl))
+ if ((m = mpls_ip6_adjttl(m, ttl)) == NULL)
goto done;
break;
#endif
rtfree(rt);
}
-int
+struct mbuf *
mpls_ip_adjttl(struct mbuf *m, u_int8_t ttl)
{
struct ip *ip;
if (mpls_mapttl_ip) {
if (m->m_len < sizeof(struct ip) &&
(m = m_pullup(m, sizeof(struct ip))) == NULL)
- return -1;
+ return NULL;
ip = mtod(m, struct ip *);
hlen = ip->ip_hl << 2;
if (m->m_len < hlen) {
if ((m = m_pullup(m, hlen)) == NULL)
- return -1;
+ return NULL;
ip = mtod(m, struct ip *);
}
/* make sure we have a valid header */
if (in_cksum(m, hlen) != 0) {
m_free(m);
- return -1;
+ return NULL;
}
/* set IP ttl from MPLS ttl */
ip->ip_sum = 0;
ip->ip_sum = in_cksum(m, hlen);
}
- return 0;
+ return m;
}
#ifdef INET6
-int
+struct mbuf *
mpls_ip6_adjttl(struct mbuf *m, u_int8_t ttl)
{
struct ip6_hdr *ip6hdr;
if (mpls_mapttl_ip6) {
if (m->m_len < sizeof(struct ip6_hdr) &&
(m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL)
- return -1;
+ return NULL;
ip6hdr = mtod(m, struct ip6_hdr *);
/* set IPv6 ttl from MPLS ttl */
ip6hdr->ip6_hlim = ttl;
}
- return 0;
+ return m;
}
#endif /* INET6 */