Module Name: src
Committed By: christos
Date: Wed Feb 17 22:32:04 UTC 2021
Modified Files:
src/sys/net: if_arp.h
src/sys/netinet: icmp_private.h igmp_var.h ip_private.h tcp_private.h
udp_private.h
src/sys/netinet6: ip6_private.h
src/sys/sys: mbuf.h param.h
Log Message:
- pass the alignment instead of the mask (as Roy asked and to match the
other macro)
- use alignof to determine that alignment and CTASSERT what we expect
- remove unused macros
To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/net/if_arp.h
cvs rdiff -u -r1.4 -r1.5 src/sys/netinet/icmp_private.h \
src/sys/netinet/ip_private.h src/sys/netinet/tcp_private.h \
src/sys/netinet/udp_private.h
cvs rdiff -u -r1.26 -r1.27 src/sys/netinet/igmp_var.h
cvs rdiff -u -r1.4 -r1.5 src/sys/netinet6/ip6_private.h
cvs rdiff -u -r1.230 -r1.231 src/sys/sys/mbuf.h
cvs rdiff -u -r1.688 -r1.689 src/sys/sys/param.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/if_arp.h
diff -u src/sys/net/if_arp.h:1.41 src/sys/net/if_arp.h:1.42
--- src/sys/net/if_arp.h:1.41 Tue Feb 16 05:20:56 2021
+++ src/sys/net/if_arp.h Wed Feb 17 17:32:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: if_arp.h,v 1.41 2021/02/16 10:20:56 martin Exp $ */
+/* $NetBSD: if_arp.h,v 1.42 2021/02/17 22:32:04 christos Exp $ */
/*
* Copyright (c) 1986, 1993
@@ -72,7 +72,8 @@ struct arphdr {
uint8_t ar_tpa[]; /* target protocol address */
#endif
};
-#define ARP_HDR_ALIGNMENT 1
+#define ARP_HDR_ALIGNMENT __alignof(struct arphdr)
+__CTASSERT(ARP_HDR_ALIGNMENT == 2);
static __inline uint8_t *
ar_data(struct arphdr *ap)
Index: src/sys/netinet/icmp_private.h
diff -u src/sys/netinet/icmp_private.h:1.4 src/sys/netinet/icmp_private.h:1.5
--- src/sys/netinet/icmp_private.h:1.4 Sun Feb 14 15:58:35 2021
+++ src/sys/netinet/icmp_private.h Wed Feb 17 17:32:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: icmp_private.h,v 1.4 2021/02/14 20:58:35 christos Exp $ */
+/* $NetBSD: icmp_private.h,v 1.5 2021/02/17 22:32:04 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -44,7 +44,6 @@ extern percpu_t *icmpstat_percpu;
#define ICMP_STATINC(x) _NET_STATINC(icmpstat_percpu, x)
-#define ICMP_HDR_ALIGNMENT 3
#endif /* _KERNEL_ */
#endif /* !_NETINET_ICMP_PRIVATE_H_ */
Index: src/sys/netinet/ip_private.h
diff -u src/sys/netinet/ip_private.h:1.4 src/sys/netinet/ip_private.h:1.5
--- src/sys/netinet/ip_private.h:1.4 Sun Feb 14 15:58:35 2021
+++ src/sys/netinet/ip_private.h Wed Feb 17 17:32:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_private.h,v 1.4 2021/02/14 20:58:35 christos Exp $ */
+/* $NetBSD: ip_private.h,v 1.5 2021/02/17 22:32:04 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -43,7 +43,8 @@ extern percpu_t *ipstat_percpu;
#define IP_STATINC(x) _NET_STATINC(ipstat_percpu, x)
#define IP_STATDEC(x) _NET_STATDEC(ipstat_percpu, x)
-#define IP_HDR_ALIGNMENT 3
+#define IP_HDR_ALIGNMENT __alignof(struct ip)
+__CTASSERT(IP_HDR_ALIGNMENT == 4);
#endif /* _KERNEL */
#endif /* !_NETINET_IP_PRIVATE_H_ */
Index: src/sys/netinet/tcp_private.h
diff -u src/sys/netinet/tcp_private.h:1.4 src/sys/netinet/tcp_private.h:1.5
--- src/sys/netinet/tcp_private.h:1.4 Sun Feb 14 15:58:35 2021
+++ src/sys/netinet/tcp_private.h Wed Feb 17 17:32:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_private.h,v 1.4 2021/02/14 20:58:35 christos Exp $ */
+/* $NetBSD: tcp_private.h,v 1.5 2021/02/17 22:32:04 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -43,7 +43,8 @@ extern percpu_t *tcpstat_percpu;
#define TCP_STATINC(x) _NET_STATINC(tcpstat_percpu, x)
#define TCP_STATADD(x, v) _NET_STATADD(tcpstat_percpu, x, v)
-#define TCP_HDR_ALIGNMENT 3
+#define TCP_HDR_ALIGNMENT __alignof(struct tcphdr)
+__CTASSERT(TCP_HDR_ALIGNMENT == 4);
#endif /* _KERNEL */
#endif /* !_NETINET_TCP_PRIVATE_H_ */
Index: src/sys/netinet/udp_private.h
diff -u src/sys/netinet/udp_private.h:1.4 src/sys/netinet/udp_private.h:1.5
--- src/sys/netinet/udp_private.h:1.4 Sun Feb 14 15:58:35 2021
+++ src/sys/netinet/udp_private.h Wed Feb 17 17:32:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: udp_private.h,v 1.4 2021/02/14 20:58:35 christos Exp $ */
+/* $NetBSD: udp_private.h,v 1.5 2021/02/17 22:32:04 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -39,7 +39,8 @@ extern percpu_t *udpstat_percpu;
#define UDP_STATINC(x) _NET_STATINC(udpstat_percpu, x)
-#define UDP_HDR_ALIGNMENT 3
+#define UDP_HDR_ALIGNMENT __alignof(struct udphdr)
+__CTASSERT(UDP_HDR_ALIGNMENT == 2);
#endif /* _KERNEL */
#endif /* !_NETINET_UDP_PRIVATE_H_ */
Index: src/sys/netinet/igmp_var.h
diff -u src/sys/netinet/igmp_var.h:1.26 src/sys/netinet/igmp_var.h:1.27
--- src/sys/netinet/igmp_var.h:1.26 Sun Feb 14 15:58:35 2021
+++ src/sys/netinet/igmp_var.h Wed Feb 17 17:32:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: igmp_var.h,v 1.26 2021/02/14 20:58:35 christos Exp $ */
+/* $NetBSD: igmp_var.h,v 1.27 2021/02/17 22:32:04 christos Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -105,8 +105,6 @@
*/
#define IGMP_RANDOM_DELAY(X) (cprng_fast32() % (X) + 1)
-#define IGMP_HDR_ALIGNMENT 3
-
void igmp_init(void);
void igmp_input(struct mbuf *, int, int);
int igmp_joingroup(struct in_multi *);
Index: src/sys/netinet6/ip6_private.h
diff -u src/sys/netinet6/ip6_private.h:1.4 src/sys/netinet6/ip6_private.h:1.5
--- src/sys/netinet6/ip6_private.h:1.4 Sun Feb 14 15:58:35 2021
+++ src/sys/netinet6/ip6_private.h Wed Feb 17 17:32:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_private.h,v 1.4 2021/02/14 20:58:35 christos Exp $ */
+/* $NetBSD: ip6_private.h,v 1.5 2021/02/17 22:32:04 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -43,7 +43,8 @@ extern percpu_t *ip6stat_percpu;
#define IP6_STATINC(x) _NET_STATINC(ip6stat_percpu, x)
#define IP6_STATDEC(x) _NET_STATDEC(ip6stat_percpu, x)
-#define IP6_HDR_ALIGNMENT 3
+#define IP6_HDR_ALIGNMENT __alignof(struct ip6_hdr)
+__CTASSERT(IP6_HDR_ALIGNMENT == 4);
#endif /* _KERNEL */
#endif /* !_NETINET_IP6_PRIVATE_H_ */
Index: src/sys/sys/mbuf.h
diff -u src/sys/sys/mbuf.h:1.230 src/sys/sys/mbuf.h:1.231
--- src/sys/sys/mbuf.h:1.230 Mon Feb 15 04:29:56 2021
+++ src/sys/sys/mbuf.h Wed Feb 17 17:32:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: mbuf.h,v 1.230 2021/02/15 09:29:56 kre Exp $ */
+/* $NetBSD: mbuf.h,v 1.231 2021/02/17 22:32:04 christos Exp $ */
/*
* Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -846,10 +846,11 @@ m_copy_rcvif(struct mbuf *m, const struc
static __inline int
m_get_aligned_hdr(struct mbuf **m, int align, size_t hlen, bool linkhdr)
{
- if (POINTER_ALIGNED_P(mtod(*m, void *), align) == 0)
+ if (POINTER_ALIGNED_P(mtod(*m, void *), align) == 0) {
+ --align; // Turn into mask
*m = m_copyup(*m, hlen,
linkhdr ? (max_linkhdr + align) & ~align : 0);
- else if (__predict_false((size_t)(*m)->m_len < hlen))
+ } else if (__predict_false((size_t)(*m)->m_len < hlen))
*m = m_pullup(*m, hlen);
return *m == NULL;
}
Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.688 src/sys/sys/param.h:1.689
--- src/sys/sys/param.h:1.688 Mon Feb 15 14:46:53 2021
+++ src/sys/sys/param.h Wed Feb 17 17:32:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.688 2021/02/15 19:46:53 christos Exp $ */
+/* $NetBSD: param.h,v 1.689 2021/02/17 22:32:04 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -290,7 +290,7 @@
#ifdef __NO_STRICT_ALIGNMENT
#define POINTER_ALIGNED_P(p, a) 1
#else
-#define POINTER_ALIGNED_P(p, a) (((uintptr_t)(p) & (a)) == 0)
+#define POINTER_ALIGNED_P(p, a) (((uintptr_t)(p) & ((a) - 1)) == 0)
#endif
/*