On 07/05/15 15:17, Martin Lucina wrote:
However, I don't see the NFS code on nxr.netbsd.org using "nam" as a
"struct sockaddr":

http://nxr.netbsd.org/source/xref/src/sys/nfs/nfs_bootdhcp.c#585

nxr is not updating for whatever reason.

"oneshot" in the ipv4 version means that it does not properly
implement leases.  Does that apply here too?  I don't think so,
right?

No, I borrowed the term to mean "sends an RS packet and does not wait to
see if an RA arrived". Ie. no feedback on whether or not the interface did
get configured. Ideally we'd wait for an RA, wait to see the kernel
actually configured an address and tell the user what it is.

I'd pick a different term for a different meaning.

+       nam = m_get(M_WAIT, MT_SONAME);
+       sin6 = mtod(nam, struct sockaddr_in6 *);

I forget what the rules are exactly, but you might technically need
to m_pulldown() before you're allowed to mtod for such a large
structure.

Should no longer be relevant if I understand what you're saying about nam
now being a "struct sockaddr"?

Right.

+       sin6->sin6_len = nam->m_len = sizeof (*sin6);

Don't you need to set nam->m_pkthdr.len?

The nfs code doesn't....

... and that doesn't mean one damn thing. It's amazing how often code is simply wrong.

(I'm not sure here, I haven't written any mbuf-heavy code in 10 years, just saying that you should actually check it instead of trusting one arbitrarily picked example)

+       rs = (struct nd_router_solicit *)buf;
+       rs->nd_rs_type = ND_ROUTER_SOLICIT;
+       buf += sizeof (*rs);
+       opt = (struct nd_opt_hdr *)buf;

Is "opt" *guaranteed* to be properly aligned?  If yes, you can do it
that way.  If no, you need to memcpy to the final space.  Probably
safer to memcpy().

sizeof (struct nd_router_solicit) is 8, so should be fine.

I think at least SPARCv9 requires 16 byte alignment.

+       if (rv != 0)
+               goto out;
+       m = nam = NULL;
+       rv = 0;

So you fix these 4 lines to m = nam = NULL;

Not sure what you mean here?

I mean that if so_send fails, your initial code will not work properly.

Reply via email to