Re: sin_family not checked for UDP sockets?

Kaz Kylheku (kaz@cafe.net)
Mon, 08 Mar 1999 19:51:08 -0800


> I was looking at the Linux sockets code, and noticed that address family
> (sockaddr_in.sin_family) doesn't get checked on a bind() to a datagram
> socket. Only the address length is verified. (I'm looking at inet_bind(),
> in net/ipv4/af_inet.c)

Why bother checking that field? The address family is redundant information;
when you created the socket, you already specified the family.

If you consider it an error, stick an assert() into your program.

Returning EINVAL would only risk breaking programs that don't set the
address family field; it would not provide any added functionality to
programs that do set the field.

-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.rutgers.edu