Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Sprinkle CTASSERT to enforce on-wire layout without __pa...



details:   https://anonhg.NetBSD.org/src/rev/229dc1dae6ee
branches:  trunk
changeset: 951470:229dc1dae6ee
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Feb 03 11:53:43 2021 +0000

description:
Sprinkle CTASSERT to enforce on-wire layout without __packed

diffstat:

 sys/net/if_arp.h        |  5 ++++-
 sys/net/if_ether.h      |  7 ++++++-
 sys/net/if_gre.h        |  5 ++++-
 sys/netinet/if_ether.h  |  3 ++-
 sys/netinet/igmp.h      |  5 ++++-
 sys/netinet/in.h        |  5 ++++-
 sys/netinet/ip.h        |  8 +++++++-
 sys/netinet/ip6.h       |  4 +++-
 sys/netinet/ip_icmp.h   |  9 ++++++++-
 sys/netinet/ip_mroute.h |  5 ++++-
 sys/netinet/ip_var.h    |  5 ++++-
 sys/netinet/tcp.h       |  5 ++++-
 sys/netinet/tcp_var.h   |  5 ++++-
 sys/netinet/udp.h       |  5 ++++-
 sys/netinet/udp_var.h   |  5 ++++-
 15 files changed, 66 insertions(+), 15 deletions(-)

diffs (289 lines):

diff -r d9e5db130e5d -r 229dc1dae6ee sys/net/if_arp.h
--- a/sys/net/if_arp.h  Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/net/if_arp.h  Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.h,v 1.35 2021/02/03 10:31:10 roy Exp $  */
+/*     $NetBSD: if_arp.h,v 1.36 2021/02/03 11:53:43 roy Exp $  */
 
 /*
  * Copyright (c) 1986, 1993
@@ -72,6 +72,9 @@
        uint8_t  ar_tpa[];      /* target protocol address */
 #endif
 };
+#ifdef CTASSERT
+CTASSERT(sizeof(struct arphdr) == 8);
+#endif
 
 static __inline uint8_t *
 ar_data(struct arphdr *ap)
diff -r d9e5db130e5d -r 229dc1dae6ee sys/net/if_ether.h
--- a/sys/net/if_ether.h        Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/net/if_ether.h        Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ether.h,v 1.82 2021/02/03 05:51:40 roy Exp $        */
+/*     $NetBSD: if_ether.h,v 1.83 2021/02/03 11:53:43 roy Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -90,6 +90,11 @@
        uint16_t ether_type;
 };
 
+#ifdef CTASSERT
+CTASSERT(sizeof(struct ether_addr) == 6);
+CTASSERT(sizeof(struct ether_header) == 14);
+#endif
+
 #include <net/ethertypes.h>
 
 #define        ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
diff -r d9e5db130e5d -r 229dc1dae6ee sys/net/if_gre.h
--- a/sys/net/if_gre.h  Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/net/if_gre.h  Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gre.h,v 1.45 2021/02/03 05:51:40 roy Exp $ */
+/*     $NetBSD: if_gre.h,v 1.46 2021/02/03 11:53:43 roy Exp $ */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -131,6 +131,9 @@
                                Present if (rt_pres == 1)
  */
 };
+#ifdef CTASSERT
+CTASSERT(sizeof(struct gre_h) == 4);
+#endif
 
 #define GRE_CP         0x8000  /* Checksum Present */
 #define GRE_RP         0x4000  /* Routing Present */
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/if_ether.h
--- a/sys/netinet/if_ether.h    Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/if_ether.h    Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ether.h,v 1.35 2021/02/03 05:51:40 roy Exp $        */
+/*     $NetBSD: if_ether.h,v 1.36 2021/02/03 11:53:43 roy Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -76,6 +76,7 @@
        u_int8_t arp_tha[ETHER_ADDR_LEN];       /* target hardware address */
        u_int8_t arp_tpa[4];                    /* target protocol address */
 };
+CTASSERT(sizeof(struct ether_arp) == 28);
 #define        arp_hrd ea_hdr.ar_hrd
 #define        arp_pro ea_hdr.ar_pro
 #define        arp_hln ea_hdr.ar_hln
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/igmp.h
--- a/sys/netinet/igmp.h        Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/igmp.h        Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: igmp.h,v 1.13 2021/02/03 05:51:40 roy Exp $    */
+/*     $NetBSD: igmp.h,v 1.14 2021/02/03 11:53:43 roy Exp $    */
 
 /*
  * Copyright (c) 1992, 1993
@@ -89,6 +89,9 @@
        uint16_t        igmp_cksum;     /* IP-style checksum               */
        struct in_addr  igmp_group;     /* group address being reported    */
 };                     /*  (zero for queries)             */
+#ifdef CTASSERT
+CTASSERT(sizeof(struct igmp) == 8);
+#endif
 
 #define        IGMP_MINLEN                     8
 
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/in.h
--- a/sys/netinet/in.h  Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/in.h  Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in.h,v 1.112 2021/02/03 05:51:40 roy Exp $     */
+/*     $NetBSD: in.h,v 1.113 2021/02/03 11:53:43 roy Exp $     */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -158,6 +158,9 @@
 struct in_addr {
        in_addr_t s_addr;
 };
+#ifdef CTASSERT
+CTASSERT(sizeof(struct in_addr) == 4);
+#endif
 
 /*
  * Definitions of bits in internet address integers.
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/ip.h
--- a/sys/netinet/ip.h  Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/ip.h  Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip.h,v 1.36 2021/02/03 05:51:40 roy Exp $      */
+/*     $NetBSD: ip.h,v 1.37 2021/02/03 11:53:43 roy Exp $      */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -248,4 +248,10 @@
        u_int16_t       ippseudo_len;   /* protocol length */
 };
 
+#ifdef CTASSERT
+CTASSERT(sizeof(struct ip) == 20);
+CTASSERT(sizeof(struct ip_timestamp) == 12);
+CTASSERT(sizeof(struct ippseudo) == 12);
+#endif
+
 #endif /* !_NETINET_IP_H_ */
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/ip6.h
--- a/sys/netinet/ip6.h Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/ip6.h Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6.h,v 1.27 2021/02/03 05:51:40 roy Exp $     */
+/*     $NetBSD: ip6.h,v 1.28 2021/02/03 11:53:43 roy Exp $     */
 /*     $KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $   */
 
 /*
@@ -120,6 +120,8 @@
        u_int8_t        ip6ph_zero[3];
        u_int8_t        ip6ph_nxt;
 };
+CTASSERT(sizeof(struct ip6_hdr) == 40);
+CTASSERT(sizeof(struct ip6_hdr_pseudo) == 40);
 #endif
 
 /*
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/ip_icmp.h
--- a/sys/netinet/ip_icmp.h     Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/ip_icmp.h     Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_icmp.h,v 1.41 2021/02/03 05:51:40 roy Exp $ */
+/*     $NetBSD: ip_icmp.h,v 1.42 2021/02/03 11:53:43 roy Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -160,6 +160,13 @@
        uint8_t c_type;
 };
 
+#ifdef CTASSERT
+CTASSERT(sizeof(struct icmp_ra_addr) == 8);
+CTASSERT(sizeof(struct icmp) == 28);
+CTASSERT(sizeof(struct icmp_ext_hdr) == 4);
+CTASSERT(sizeof(struct icmp_ext_obj_hdr) == 4);
+#endif
+
 /*
  * Lower bounds on packet lengths for various types.
  * For the error advice packets must first insure that the
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/ip_mroute.h
--- a/sys/netinet/ip_mroute.h   Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/ip_mroute.h   Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_mroute.h,v 1.33 2021/02/03 05:51:40 roy Exp $       */
+/*     $NetBSD: ip_mroute.h,v 1.34 2021/02/03 11:53:43 roy Exp $       */
 
 #ifndef _NETINET_IP_MROUTE_H_
 #define _NETINET_IP_MROUTE_H_
@@ -284,6 +284,9 @@
        u_int8_t  unused3;
        struct    in_addr im_src, im_dst;
 };
+#ifdef CTASSERT
+CTASSERT(sizeof(struct igmpmsg) == 20);
+#endif
 
 /*
  * Argument structure used for pkt info. while upcall is made.
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/ip_var.h
--- a/sys/netinet/ip_var.h      Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/ip_var.h      Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_var.h,v 1.131 2021/02/03 05:51:40 roy Exp $ */
+/*     $NetBSD: ip_var.h,v 1.132 2021/02/03 11:53:43 roy Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -47,6 +47,9 @@
        struct    in_addr ih_src;       /* source internet address */
        struct    in_addr ih_dst;       /* destination internet address */
 };
+#ifdef CTASSERT
+CTASSERT(sizeof(struct ipovly) == 20);
+#endif
 
 /*
  * IP Flow structure
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/tcp.h
--- a/sys/netinet/tcp.h Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/tcp.h Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp.h,v 1.35 2021/02/03 05:51:40 roy Exp $     */
+/*     $NetBSD: tcp.h,v 1.36 2021/02/03 11:53:43 roy Exp $     */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -73,6 +73,9 @@
        uint16_t th_sum;                        /* checksum */
        uint16_t th_urp;                        /* urgent pointer */
 };
+#ifdef CTASSERT
+CTASSERT(sizeof(struct tcphdr) == 20);
+#endif
 
 #define        TCPOPT_EOL              0
 #define           TCPOLEN_EOL                  1
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/tcp_var.h
--- a/sys/netinet/tcp_var.h     Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/tcp_var.h     Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_var.h,v 1.193 2021/02/03 05:51:40 roy Exp $        */
+/*     $NetBSD: tcp_var.h,v 1.194 2021/02/03 11:53:43 roy Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -169,6 +169,9 @@
        struct ipovly ti_i;             /* overlaid ip structure */
        struct tcphdr ti_t;             /* tcp header */
 };
+#ifdef CTASSERT
+CTASSERT(sizeof(struct tcpiphdr) == 40);
+#endif
 #define        ti_x1           ti_i.ih_x1
 #define        ti_pr           ti_i.ih_pr
 #define        ti_len          ti_i.ih_len
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/udp.h
--- a/sys/netinet/udp.h Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/udp.h Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: udp.h,v 1.17 2021/02/03 05:51:40 roy Exp $     */
+/*     $NetBSD: udp.h,v 1.18 2021/02/03 11:53:43 roy Exp $     */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -45,6 +45,9 @@
        uint16_t uh_ulen;               /* udp length */
        uint16_t uh_sum;                /* udp checksum */
 };
+#ifdef CTASSERT
+CTASSERT(sizeof(struct udphdr) == 8);
+#endif
 
 /* socket options for UDP */
 #define        UDP_ENCAP       100
diff -r d9e5db130e5d -r 229dc1dae6ee sys/netinet/udp_var.h
--- a/sys/netinet/udp_var.h     Wed Feb 03 11:52:23 2021 +0000
+++ b/sys/netinet/udp_var.h     Wed Feb 03 11:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: udp_var.h,v 1.47 2021/02/03 05:51:40 roy Exp $ */
+/*     $NetBSD: udp_var.h,v 1.48 2021/02/03 11:53:43 roy Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -41,6 +41,9 @@
        struct  ipovly ui_i;            /* overlaid ip structure */
        struct  udphdr ui_u;            /* udp header */
 };
+#ifdef CTASSERT
+CTASSERT(sizeof(struct udpiphdr) == 28);
+#endif
 #define        ui_x1           ui_i.ih_x1
 #define        ui_pr           ui_i.ih_pr
 #define        ui_len          ui_i.ih_len



Home | Main Index | Thread Index | Old Index