From owner-freebsd-current Mon Apr 1 16:33:37 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id QAA16502 for current-outgoing; Mon, 1 Apr 1996 16:33:37 -0800 (PST) Received: from who.cdrom.com (who.cdrom.com [204.216.27.3]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id QAA16497 for ; Mon, 1 Apr 1996 16:33:34 -0800 (PST) Received: from palmer.demon.co.uk (palmer.demon.co.uk [158.152.50.150]) by who.cdrom.com (8.6.12/8.6.11) with ESMTP id QAA22798 for ; Mon, 1 Apr 1996 16:33:26 -0800 Received: from localhost (localhost [127.0.0.1]) by palmer.demon.co.uk (8.7.5/8.6.11) with SMTP id BAA03280 for ; Tue, 2 Apr 1996 01:31:59 +0100 (BST) To: FreeBSD-Current From: "Gary Palmer" Subject: Linker sets & structures for networking code Date: Tue, 02 Apr 1996 01:31:58 +0100 Message-ID: <3278.828405118@palmer.demon.co.uk> Sender: owner-current@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Hi There seems to be something fundamentally WRONG in some of the networking stuff which I'm not sure how to fix. (I'm going through LINT trying to fix as many warnings as I can). People have noticed warnings like: ../../kern/uipc_proto.c:62: warning: initialization from incompatible pointer type If you look, the error is part of this structure: static struct protosw localsw[] = { [snip snip] { 0, 0, 0, 0, raw_input, 0, raw_ctlinput, 0, raw_usrreq, raw_init, 0, 0, 0, } }; (the error comes from the `raw_input' initialiser); /sys/sys/protosw.h defines the input field to be: void (*pr_input) __P((struct mbuf *, int len)); raw_input is prototyped as: void raw_input __P((struct mbuf *, struct sockproto *, struct sockaddr *, struct sockaddr *)); /sys/net/raw_usrreq.c says: void raw_input(m0, proto, src, dst) struct mbuf *m0; register struct sockproto *proto; struct sockaddr *src, *dst; { register struct rawcb *rp; register struct mbuf *m = m0; register int sockets = 0; struct socket *last; last = 0; for (rp = rawcb.rcb_next; rp != &rawcb; rp = rp->rcb_next) { if (rp->rcb_proto.sp_family != proto->sp_family) continue; So if raw_input is called with the parameters as defined by (*pr_input), the first thing it does is pull a pile of garbage off the stack. Which brings me to another problem with this code. The first field of the `protosw' structure is: short pr_type; /* socket type used for */ Which (if I understand the way this works right - I haven't been able to backtrack through the networking code enough to verify this) is used to match the requested protocol type against available protocol types. Since (in uipc_proto.c) pr_type for the raw_* stuff is declared as `0', I can't see how raw_input ever gets call via the localsw array. (Infact there are several examples of `raw_input' being called which bypasses localsw totally). So why on earth is it there?!? Of course, that is just a warm up for this: ../../netinet/in_proto.c:96: warning: initialization from incompatible pointer type ../../netinet/in_proto.c:112: warning: initialization from incompatible pointer type ../../netinet/in_proto.c:117: warning: initialization from incompatible pointer type ../../netinet/in_proto.c:121: warning: initialization from incompatible pointer type ../../netinet/in_proto.c:126: warning: initialization from incompatible pointer type ../../netinet/in_proto.c:131: warning: initialization from incompatible pointer type ../../netinet/in_proto.c:152: warning: initialization from incompatible pointer type ../../netinet/in_proto.c:152: warning: initialization from incompatible pointer type ../../netinet/in_proto.c:166: warning: initialization from incompatible pointer type Which is a lot of the same :( Gary