Does getaddrinfo() need to be rebuilt for SCTP support?
I've run into some behavior of getaddrinfo() that I think may be incorrect. When getaddrinfo() is called with a numeric service argument (as opposed to a name), it returns a list of addrinfo structures for each protocol that it knows about, without referencing the /etc/services database. After installing lksctp I expected this list to include IPPROTO_SCTP, but it doesn't. It looks to me like getaddrinfo() is actually only returning addrinfo structures for all the protocols that is knew about when it was built. Is this the correct behavior? Do I need to rebuild glibc? Thanks for any help.
- Jon
I've run into some behavior of getaddrinfo() that I think may be incorrect. When getaddrinfo() is called with a numeric service argument (as opposed to a name), it returns a list of addrinfo structures for each protocol that it knows about, without referencing the /etc/services database. After installing lksctp I expected this list to include IPPROTO_SCTP, but it doesn't. It looks to me like getaddrinfo() is actually only returning addrinfo structures for all the protocols that is knew about when it was built. Is this the correct behavior? Does glibc need to be rebuilt after installing lksctp? Thanks for any help.
- Jon
RnJvbTogSm9uYXRoYW4gVC4gTGVpZ2h0b24NCj4gU2VudDogMDUgTm92ZW1iZXIgMjAxNiAxNTox NQ0KPiBJJ3ZlIHJ1biBpbnRvIHNvbWUgYmVoYXZpb3Igb2YgZ2V0YWRkcmluZm8oKSB0aGF0IEkg dGhpbmsgbWF5IGJlDQo+IGluY29ycmVjdC4gV2hlbiBnZXRhZGRyaW5mbygpIGlzIGNhbGxlZCB3 aXRoIGEgbnVtZXJpYyBzZXJ2aWNlIGFyZ3VtZW50DQo+IChhcyBvcHBvc2VkIHRvIGEgbmFtZSks IGl0IHJldHVybnMgYSBsaXN0IG9mIGFkZHJpbmZvIHN0cnVjdHVyZXMgZm9yDQo+IGVhY2ggcHJv dG9jb2wgdGhhdCBpdCBrbm93cyBhYm91dCwgd2l0aG91dCByZWZlcmVuY2luZyB0aGUgL2V0Yy9z ZXJ2aWNlcw0KPiBkYXRhYmFzZS4gQWZ0ZXIgaW5zdGFsbGluZyBsa3NjdHAgSSBleHBlY3RlZCB0 aGlzIGxpc3QgdG8gaW5jbHVkZQ0KPiBJUFBST1RPX1NDVFAsIGJ1dCBp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Hi David -
Thanks for the response.
Quoted 11 lines · David Laight
From: Jonathan T. Leighton
Quoted 10 lines
Sent: 05 November 2016 15:15
I've run into some behavior ofgetaddrinfo()that I think may be incorrect. Whengetaddrinfo()is called with a numeric service argument (as opposed to a name), it returns a list of addrinfo structures for each protocol that it knows about, without referencing the/etc/servicesdatabase. After installing lksctp I expected this list to includeIPPROTO_SCTP, but it doesn't. It looks to me likegetaddrinfo()is actually only returning addrinfo structures for all the protocols that is knew about when it was built. Is this the correct behavior? Does glibc need to be rebuilt after installing lksctp? Thanks for any help.
Quoted 2 lines
What you don't want is programs being given SCTP addresses when they don't really want them.
I'm not sure I agree with this. getaddrinfo() can return addrinfo structures with IPPROTO_UDP and IPPROTO_IP (in addition to IPPROTO_TCP)
- assuming that every returned addrinfo structure uses IPPROTO_TCP is a problem. Code needs to be able to select among the returned addrinfo structures appropriately, and including IPPROTO_SCTP shouldn't break such code.
Quoted 3 lines
I've seen problems in the past (not Linux) where programs have tried to use addresses on all available protocols when they really just meant TCP or UDP.
IMO this is just bad coding.
Quoted 5 lines
I don't think any of the address lookup functions are service specific, AA and AAAA records probably aren't even protocol specific (below IP).
So programs that want to use SCTP can lookup TCP and then substitute SCTP when they create the socket.
Sure, but this is a hack. On a system with SCTP installed, SCTP shouldn't be treated like a second class citizen.
Looking at the getaddrinfo() source shows that it's written to return addrinfo structures with IPPROTO_SCTP, but only if it is built on a system with SCTP installed. That suggests to me that installing lksctp should include replacing glibc with a version that was built with SCTP enabled.
- Jon
Quoted 2 lines
David
Quoted 27 lines · Jonathan T. Leighton
Hi David -
Thanks for the response.
Quoted 12 lines · David Laight
From: Jonathan T. Leighton
Quoted 11 lines
Sent: 05 November 2016 15:15
I've run into some behavior ofgetaddrinfo()that I think may be incorrect. Whengetaddrinfo()is called with a numeric service argument (as opposed to a name), it returns a list of addrinfo structures for each protocol that it knows about, without referencing the/etc/services
database. After installing lksctp I expected this list to includeIPPROTO_SCTP, but it doesn't. It looks to me likegetaddrinfo()is actually only returning addrinfo structures for all the protocols that is knew about when it was built. Is this the correct behavior? Does glibc need to be rebuilt after installing lksctp? Thanks for any help.Quoted 2 lines
What you don't want is programs being given SCTP addresses when they don't really want them.
I'm not sure I agree with this.
getaddrinfo()can return addrinfo structures withIPPROTO_UDPandIPPROTO_IP(in addition toIPPROTO_TCP) - assuming that every returned addrinfo structure usesIPPROTO_TCPis a problem. Code needs to be able to select among the returned addrinfo structures appropriately, and includingIPPROTO_SCTPshouldn't break such code.
Quoted 5 lines
Quoted 3 lines
I've seen problems in the past (not Linux) where programs have tried to use addresses on all available protocols when they really just meant TCP or UDP.
IMO this is just bad coding.
I think I need to revise my opinion somewhat here. I've been advised that there is significant code which assumes that protocol 0 and type SOCK_STREAM means TCP. The workaround for getaddrinfo() is to include IPPROTO_SCTP in the hints when using SCTP, and that works fine for me.
Thanks again for your input David.
- Jon
Quoted 21 lines
Quoted 6 lines
I don't think any of the address lookup functions are service specific, AA and AAAA records probably aren't even protocol specific (below IP).
So programs that want to use SCTP can lookup TCP and then substitute SCTP
when they create the socket.Sure, but this is a hack. On a system with SCTP installed, SCTP shouldn't be treated like a second class citizen.
Looking at the
getaddrinfo()source shows that it's written to return addrinfo structures withIPPROTO_SCTP, but only if it is built on a system with SCTP installed. That suggests to me that installing lksctp should include replacing glibc with a version that was built with SCTP enabled.- Jon
Quoted 2 lines
David