Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 02 Apr 1996 01:31:58 +0100
From:      "Gary Palmer" <gpalmer@FreeBSD.ORG>
To:        FreeBSD-Current <FreeBSD-Current@FreeBSD.ORG>
Subject:   Linker sets & structures for networking code
Message-ID:  <3278.828405118@palmer.demon.co.uk>

next in thread | raw e-mail | index | archive | help

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3278.828405118>