netinet6 bread crumbs

2011-04-02 Thread Stefan Sperling
Feel free to ack or reject these individually.


Kill redundant offsetof definitions. All of these files include sys/param.h.

Index: frag6.c
===
RCS file: /cvs/src/sys/netinet6/frag6.c,v
retrieving revision 1.32
diff -u -p -r1.32 frag6.c
--- frag6.c 6 Mar 2011 19:55:54 -   1.32
+++ frag6.c 19 Mar 2011 12:53:43 -
@@ -124,10 +124,6 @@ do {   
\
 
 #defineIP6Q_UNLOCK()   ip6q_unlock()
 
-#ifndef offsetof   /* XXX */
-#defineoffsetof(type, member)  ((size_t)(((type *)0)-member))
-#endif
-
 /*
  * Initialise reassembly queue and fragment identifier.
  */
Index: icmp6.c
===
RCS file: /cvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.113
diff -u -p -r1.113 icmp6.c
--- icmp6.c 9 Jul 2010 15:44:20 -   1.113
+++ icmp6.c 2 Apr 2011 11:46:06 -
@@ -1181,9 +1181,6 @@ icmp6_mtudisc_update(struct ip6ctlparam 
  * - joins NI group address at in6_ifattach() time only, does not cope
  *   with hostname changes by sethostname(3)
  */
-#ifndef offsetof   /* XXX */
-#defineoffsetof(type, member)  ((size_t)(((type *)0)-member))
-#endif
 struct mbuf *
 ni6_input(struct mbuf *m, int off)
 {
Index: in6_gif.c
===
RCS file: /cvs/src/sys/netinet6/in6_gif.c,v
retrieving revision 1.29
diff -u -p -r1.29 in6_gif.c
--- in6_gif.c   11 May 2010 09:36:07 -  1.29
+++ in6_gif.c   2 Apr 2011 11:45:41 -
@@ -69,10 +69,6 @@
 #include netinet/ip_ether.h
 #endif
 
-#ifndef offsetof
-#define offsetof(s, e) ((int)((s *)0)-e)
-#endif
-
 /*
  * family - family of the packet to be encapsulate.
  */



As of r1.54 of nd6_rtr.c we don't add addresses in interrupt context anymore.
So this allocation can now wait:

Index: in6.c
===
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.89
diff -u -p -r1.89 in6.c
--- in6.c   7 Oct 2010 22:07:06 -   1.89
+++ in6.c   2 Apr 2011 12:02:04 -
@@ -910,14 +910,7 @@ in6_update_ifa(struct ifnet *ifp, struct
 */
if (ia == NULL) {
hostIsNew = 1;
-   /*
-* When in6_update_ifa() is called in a process of a received
-* RA, it is called under an interrupt context.  So, we should
-* call malloc with M_NOWAIT.
-*/
-   ia = malloc(sizeof(*ia), M_IFADDR, M_NOWAIT | M_ZERO);
-   if (ia == NULL)
-   return (ENOBUFS);
+   ia = malloc(sizeof(*ia), M_IFADDR, M_WAITOK | M_ZERO);
LIST_INIT(ia-ia6_memberships);
/* Initialize the address and masks, and put time stamp */
ia-ia_ifa.ifa_addr = (struct sockaddr *)ia-ia_addr;



Typos in comments:

Index: ip6_input.c
===
RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.98
diff -u -p -r1.98 ip6_input.c
--- ip6_input.c 9 Sep 2010 09:46:13 -   1.98
+++ ip6_input.c 17 Dec 2010 21:54:45 -
@@ -974,8 +974,8 @@ ip6_process_hopopts(struct mbuf *m, u_in
 /*
  * Unknown option processing.
  * The third argument `off' is the offset from the IPv6 header to the option,
- * which is necessary if the IPv6 header the and option header and IPv6 header
- * is not continuous in order to return an ICMPv6 error.
+ * which allows returning an ICMPv6 error even if the IPv6 header and the
+ * option header are not continuous.
  */
 int
 ip6_unknown_opt(u_int8_t *optp, struct mbuf *m, int off)
Index: nd6.h
===
RCS file: /cvs/src/sys/netinet6/nd6.h,v
retrieving revision 1.27
diff -u -p -r1.27 nd6.h
--- nd6.h   6 Apr 2010 14:12:10 -   1.27
+++ nd6.h   24 Oct 2010 12:04:13 -
@@ -267,7 +267,7 @@ struct nd_prefix {
/* list of routers that advertise the prefix: */
LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs;
u_char  ndpr_plen;
-   int ndpr_refcnt;/* reference couter from addresses */
+   int ndpr_refcnt;/* reference counter from addresses */
 };
 
 #define ndpr_next  ndpr_entry.le_next



Re: netinet6 bread crumbs

2011-04-02 Thread Thordur Bjornsson
On Sat, Apr 02, 2011 at 02:13:45PM +0200, Stefan Sperling wrote:
 Feel free to ack or reject these individually.
 
 
 Kill redundant offsetof definitions. All of these files include sys/param.h.
Those look fine.
 
 Index: in6.c
 ===
 RCS file: /cvs/src/sys/netinet6/in6.c,v
 retrieving revision 1.89
 diff -u -p -r1.89 in6.c
 --- in6.c 7 Oct 2010 22:07:06 -   1.89
 +++ in6.c 2 Apr 2011 12:02:04 -
 @@ -910,14 +910,7 @@ in6_update_ifa(struct ifnet *ifp, struct
*/
   if (ia == NULL) {
   hostIsNew = 1;
 - /*
 -  * When in6_update_ifa() is called in a process of a received
 -  * RA, it is called under an interrupt context.  So, we should
 -  * call malloc with M_NOWAIT.
 -  */
 - ia = malloc(sizeof(*ia), M_IFADDR, M_NOWAIT | M_ZERO);
 - if (ia == NULL)
 - return (ENOBUFS);
 + ia = malloc(sizeof(*ia), M_IFADDR, M_WAITOK | M_ZERO);
This is a little bit suspect. But people who know the call path should
look at this.

typos look ok, but mah spjellingk is not vry good. (: