ipip_input outer af

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ipip_input outer af

Alexander Bluhm
Hi,

Instead of looking at the IP version of the header, we can use the
outer address family passed to ipip_input().

ok?

bluhm

Index: netinet/ip_ipip.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_ipip.c,v
retrieving revision 1.78
diff -u -p -r1.78 ip_ipip.c
--- netinet/ip_ipip.c 18 May 2017 10:56:45 -0000 1.78
+++ netinet/ip_ipip.c 19 May 2017 11:36:12 -0000
@@ -131,26 +131,21 @@ ipip_input_gif(struct mbuf **mp, int *of
 #endif
  int mode, hlen;
  u_int8_t itos, otos;
- u_int8_t v;
  sa_family_t iaf;
 
  ipipstat_inc(ipips_ipackets);
 
- m_copydata(m, 0, 1, &v);
-
- switch (v >> 4) {
- case 4:
+ switch (oaf) {
+ case AF_INET:
  hlen = sizeof(struct ip);
  break;
 #ifdef INET6
- case 6:
+ case AF_INET6:
  hlen = sizeof(struct ip6_hdr);
  break;
 #endif
  default:
- ipipstat_inc(ipips_family);
- m_freem(m);
- return IPPROTO_DONE;
+ unhandled_af(oaf);
  }
 
  /* Bring the IP header in the first mbuf, if not there already */
@@ -162,21 +157,18 @@ ipip_input_gif(struct mbuf **mp, int *of
  }
  }
 
-
  /* Keep outer ecn field. */
- switch (v >> 4) {
- case 4:
+ switch (oaf) {
+ case AF_INET:
  ipo = mtod(m, struct ip *);
  otos = ipo->ip_tos;
  break;
 #ifdef INET6
- case 6:
+ case AF_INET6:
  ip6 = mtod(m, struct ip6_hdr *);
  otos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
  break;
 #endif
- default:
- panic("%s: should never reach here", __func__);
  }
 
  /* Remove outer IP header */