Hello,How can i apply the following patch to bsd 6.5 kernel.Kindly share the
procedure to do this.
Index: mpls_output.c
===================================================================
RCS file: /cvs/src/sys/netmpls/mpls_output.c,v
retrieving revision 1.26
diff -u -6 -r1.26 mpls_output.c
--- mpls_output.c 2 Dec 2015 08:47:00 -0000 1.26
+++ mpls_output.c 23 Aug 2019 15:02:25 -0000
@@ -37,13 +37,13 @@
#ifdef MPLS_DEBUG
#define MPLS_LABEL_GET(l) ((ntohl((l) & MPLS_LABEL_MASK)) >>
MPLS_LABEL_OFFSET)
#endif
void mpls_do_cksum(struct mbuf *);
-u_int8_t mpls_getttl(struct mbuf *, sa_family_t);
+u_int8_t mpls_getttl(struct mbuf **, sa_family_t);
int
mpls_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
struct rtentry *rt)
{
struct sockaddr_mpls *smpls;
@@ -67,13 +67,17 @@
/* initialize sockaddr_mpls */
bzero(&sa_mpls, sizeof(sa_mpls));
smpls = &sa_mpls;
smpls->smpls_family = AF_MPLS;
smpls->smpls_len = sizeof(*smpls);
- ttl = mpls_getttl(m, dst->sa_family);
+ ttl = mpls_getttl(&m, dst->sa_family);
+ if (m == NULL) {
+ error = ENOBUFS;
+ goto bad;
+ }
rt_mpls = (struct rt_mpls *)rt->rt_llinfo;
if (rt_mpls == NULL || (rt->rt_flags & RTF_MPLS) == 0) {
/* no MPLS information for this entry */
if (!ISSET(ifp->if_xflags, IFXF_MPLS)) {
#ifdef MPLS_DEBUG
@@ -157,43 +161,65 @@
ip->ip_sum = in_cksum(m, hlen);
m->m_pkthdr.csum_flags &= ~M_IPV4_CSUM_OUT;
}
}
u_int8_t
-mpls_getttl(struct mbuf *m, sa_family_t af)
+mpls_getttl(struct mbuf **mp, sa_family_t af)
{
struct shim_hdr *shim;
struct ip *ip;
#ifdef INET6
struct ip6_hdr *ip6hdr;
#endif
u_int8_t ttl = mpls_defttl;
+ struct mbuf *m = *mp;
/* If the AF is MPLS then inherit the TTL from the present label. */
if (af == AF_MPLS) {
+
+ m = m_pullup(m, sizeof(*shim));
+ if (m == NULL) {
+ *mp = NULL;
+ return 0;
+ }
+
shim = mtod(m, struct shim_hdr *);
ttl = ntohl(shim->shim_label & MPLS_TTL_MASK);
return (ttl);
}
/* Else extract TTL from the encapsualted packet. */
switch (*mtod(m, u_char *) >> 4) {
case IPVERSION:
if (!mpls_mapttl_ip)
break;
if (m->m_len < sizeof(*ip))
break; /* impossible */
+
+ m = m_pullup(m, sizeof(*ip));
+ if (m == NULL) {
+ *mp = NULL;
+ return 0;
+ }
+
ip = mtod(m, struct ip *);
ttl = ip->ip_ttl;
break;
#ifdef INET6
case IPV6_VERSION >> 4:
if (!mpls_mapttl_ip6)
break;
if (m->m_len < sizeof(struct ip6_hdr))
break; /* impossible */
+
+ m = m_pullup(m, sizeof(*ip6hdr));
+ if (m == NULL) {
+ *mp = NULL;
+ return 0;
+ }
+
ip6hdr = mtod(m, struct ip6_hdr *);
ttl = ip6hdr->ip6_hlim;
break;
#endif
default:
break;
--
Sent from:
http://openbsd-archive.7691.n7.nabble.com/openbsd-dev-bugs-f183916.html