[PATCH] c/r: Add AF_UNIX support (v3)

Dan Smith danms at us.ibm.com
Mon Jul 6 15:12:01 PDT 2009

OL> (You'll need to slightly refactor sock_setsockopt() for that).

It seems much easier and less invasive to just check against
sysctl_{r,w}mem_max.  I've got that added to the patch now.

OL> 2) 	s = socket(.., SOCK_DGRAM,...);
OL> 	bind(s, any_addr);
OL> 	connect(s, other_addr, ...);
--> now s is connected, but after restart you can't connect another
OL> socket to it because the address wasn't bind() properly.

Okay, I guess that's true.  So, since there isn't a "I'm bound, but
not listening or connected" flag anywhere, does it suffice to bind()
any socket that is not connected but that does have a local address?
Sockets that get a local address via connect() should never transition
through that state, so I think that should work.  At least for INET,
any socket that is restored into a connected state is properly hashed
such that another socket can't bind() to its local address (tested).

OL> (And if the address was a pathname, but already unlinked, then
OL> also unlink after the bind, FWIW).

For path-based UNIX sockets, we don't care about this exclusion,
right?  As long as we make the socket owner think everything is as it
was, that is.  Given that a normal system doesn't fail the bind of b
in this case:

  a = socket(AF_UNIX);
  b = socket(AF_UNIX);

  bind(a, addr);
  bind(b, addr);

Dan Smith
IBM Linux Technology Center
email: danms at us.ibm.com

More information about the Containers mailing list