Skip to contentSkip to conversation

bind and O_NONBLOCK

DISCUSSION Ulrich Drepper 4 participants 11 messages Sep 21, 2007 – Sep 28, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Some time back Alan asked about adding O_NONBLOCK support to bind in the POSIX spec. I brought this up and the following text will be in the next revision of the POSIX spec:

=======================
If the socket address cannot be assigned immediately and O_NONBLOCK is set for the file descriptor for the socket, bind( ) shall fail and set errno to [EINPROGRESS], but the assignment request shall not be aborted, and the assignment shall be completed asynchronously. Subsequent calls to bind() for the same socket, before the assignment is completed, shall fail and set errno to [EALREADY].

When the assignment has been performed asynchronously, pselect(), select(), and poll() shall indicate that the file descriptor for the socket is ready for reading and writing.
=======================

It would be ideal if we'd have such an implementation in the next few months so that we, in theory, can check whether the text in the specification makes sense.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖ -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFG813Z2ijCOnn/RHQRAsNkAJ9EuDWX3EDez8+o/y3I39A7Axy++ACfZAXi DRFm1UadrbJ+c7ss0a1vWUI=
=p1bV
-----END PGP SIGNATURE-----

#1 lore raw

Hi Ulrich.

Quoted 12 lines · Ulrich Drepper

Some time back Alan asked about adding O_NONBLOCK support to bind in the POSIX spec. I brought this up and the following text will be in the next revision of the POSIX spec:

=======================
If the socket address cannot be assigned immediately and O_NONBLOCK is set for the file descriptor for the socket, bind( ) shall fail and set errno to [EINPROGRESS], but the assignment request shall not be aborted, and the assignment shall be completed asynchronously. Subsequent calls to bind() for the same socket, before the assignment is completed, shall fail and set errno to [EALREADY].

Quoted 8 lines

When the assignment has been performed asynchronously, pselect(), select(), and poll() shall indicate that the file descriptor for the socket is ready for reading and writing.
=======================

It would be ideal if we'd have such an implementation in the next few months so that we, in theory, can check whether the text in the specification makes sense.

On behalf of which process this is supposed to be done? Network does not have any async processing units to perform this kind of operations. There are four ways where bind can fail:

1. unsufficient rights - nothing can help here
2. there is no memory - async binding can not help here too, since it some memory just has to be allocated to save async request somewhere.
3. socket is locked.
4. addres is being bound is in use.

We can wait until it is released and perform binding on behalf of some other process in both situations, although I think we do not want 4'th variant in some cases.

So, did I understand you correctly, that you want to introduce network AIO here? (for example on behalf of work queue or something else?)

Signature · 1 line
	Evgeniy Polyakov
#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 2 lines · Evgeniy Polyakov

So, did I understand you correctly, that you want to introduce network AIO here? (for example on behalf of work queue or something else?)

See Alan's mail. All this was his proposal, I just got it accepted upstream.

The problem to solve is if you have a distributed network port set. Apparently NetBIOS has it but I could also imagine this to be useful in cluster implementations which have to appear as one machine. In this case, before binding to a given port, you have to make sure no other machine already handles this port.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖ -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFG9UDy2ijCOnn/RHQRAvntAKC6F6Pz6zHd/iZLFECOZ0MxlhdPBQCgjrLC V9cazPF5jjf2eUSr7ZKDSas=
=0v1W
-----END PGP SIGNATURE-----

#3 lore raw
Quoted 4 lines · Ulrich Drepper
Quoted 2 lines · Evgeniy Polyakov

So, did I understand you correctly, that you want to introduce network AIO here? (for example on behalf of work queue or something else?)

Quoted 8 lines

See Alan's mail. All this was his proposal, I just got it accepted upstream.

The problem to solve is if you have a distributed network port set. Apparently NetBIOS has it but I could also imagine this to be useful in cluster implementations which have to appear as one machine. In this case, before binding to a given port, you have to make sure no other machine already handles this port.

Yes, to handle bind conflict in some or another way.
Could you point to the original Alan's proposal, I only found short note (as in you original mail) at opengroup.org and failed to correctly googlify it in the web.

Signature · 1 line
	Evgeniy Polyakov
#4 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 3 lines · Evgeniy Polyakov

Could you point to the original Alan's proposal, I only found short note (as in you original mail) at opengroup.org and failed to correctly googlify it in the web.

There was no public mail. I asked RH engineering for proposals for changes to the POSIX spec and Alan replied.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖ -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFG9Uyl2ijCOnn/RHQRAtyNAJ0TLrZ8P3VcoFDWT1g+Qft1eTU+1QCffus6 Tljy9S9Sxb7z09l/GBkLSvY=
=golD
-----END PGP SIGNATURE-----

#5 lore raw
Quoted 7 lines · Ulrich Drepper
Quoted 3 lines · Evgeniy Polyakov

Could you point to the original Alan's proposal, I only found short note (as in you original mail) at opengroup.org and failed to correctly googlify it in the web.

There was no public mail. I asked RH engineering for proposals for changes to the POSIX spec and Alan replied.

Then I belive RH engineers will implement this issue and you should not send this to netdev@ (maybe only as a warning for all others :)

Signature · 1 line
	Evgeniy Polyakov
maintainer
#6 lore raw
In reply to Ulrich Drepper

From: Ulrich Drepper <[email protected]>
Date: Sat, 22 Sep 2007 10:11:01 -0700

Quoted 2 lines

There was no public mail. I asked RH engineering for proposals for changes to the POSIX spec and Alan replied.

Please do not discuss such proposals only privately, especially when the ramifications affect the entire community.

It is important the things get hashed out on a public forum where all networking developers can add their insight into the problem.

#7 lore raw
Quoted 11 lines · David Miller

From: Ulrich Drepper <[email protected]>
Date: Sat, 22 Sep 2007 10:11:01 -0700

Quoted 2 lines

There was no public mail. I asked RH engineering for proposals for changes to the POSIX spec and Alan replied.

Please do not discuss such proposals only privately, especially when the ramifications affect the entire community.

It is important the things get hashed out on a public forum where all networking developers can add their insight into the problem.

It was - about six years ago while netbeui/netbios merging was being discussed. It got tagged then and finally ended up here.

#8 lore raw
In reply to Evgeniy Polyakov
Quoted 8 lines · Evgeniy Polyakov

of operations. There are four ways where bind can fail:

1. unsufficient rights - nothing can help here
2. there is no memory - async binding can not help here too, since it some memory just has to be allocated to save async request somewhere.
3. socket is locked.
4. addres is being bound is in use.

For most protocols yes - but not all. For things like IP specifying O_NDELAY is meaningless on a bind it will always complete on the spot as you say

#9 lore raw
Quoted 10 lines · Alan Cox
Quoted 8 lines · Evgeniy Polyakov

of operations. There are four ways where bind can fail:

1. unsufficient rights - nothing can help here
2. there is no memory - async binding can not help here too, since it some memory just has to be allocated to save async request somewhere.
3. socket is locked.
4. addres is being bound is in use.

Quoted 2 lines

For most protocols yes - but not all. For things like IP specifying O_NDELAY is meaningless on a bind it will always complete on the spot as you say

Yes, of course, bind conflict can be handled in different way as Ulrich noted - from checking bind bucket, to request remote node if address is in use or not.

Signature · 1 line
	Evgeniy Polyakov
maintainer
#10 lore raw
In reply to Ulrich Drepper

From: Ulrich Drepper <[email protected]>
Date: Thu, 20 Sep 2007 22:59:53 -0700

Quoted 3 lines

It would be ideal if we'd have such an implementation in the next few months so that we, in theory, can check whether the text in the specification makes sense.

It seems this functionality is only relevant for really ancient protocols such as netbeui, as Alan mentioned.

The implementation would go in those protocols, the code for which hasn't been touched substantially for years. It is unclear whether those protocols are even functional at this time. :-)

So expecting an implementation in the next few months depends upon someone standing up and actively working on those rotting code bases.