Date: Fri, 21 Dec 2012 04:11:48 -0800 From: Garrett Cooper <yanegomi@gmail.com> To: Kevin Lo <kevlo@freebsd.org> Cc: src-committers@freebsd.org, freebsd-net@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, Rick Macklem <rmacklem@uoguelph.ca> Subject: Broken error handling with AF_* and socket(2) [was Re: svn commit: r243965 - in head/sys: kern sys] Message-ID: <CAGH67wQhapDDqGjKGgdBwNR7GsJBwTk7Fh7tCuCV4zh7B-Yduw@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
--e89a8ff2535c7d472104d15bc0b0 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Dec 6, 2012 at 6:22 PM, Kevin Lo <kevlo@freebsd.org> wrote: > Author: kevlo > Date: Fri Dec 7 02:22:48 2012 > New Revision: 243965 > URL: http://svnweb.freebsd.org/changeset/base/243965 > > Log: > - according to POSIX, make socket(2) return EAFNOSUPPORT rather than > EPROTONOSUPPORT if the address family is not supported. > - introduce pffinddomain() to find a domain by family and use it as > appropriate. > > Reviewed by: glebius This commit broke netgraph (and potentially more things). I fixed netgraph locally like so: $ git diff lib/libnetgraph/ diff --git a/lib/libnetgraph/sock.c b/lib/libnetgraph/sock.c index fca3900..5f9f563 100644 --- a/lib/libnetgraph/sock.c +++ b/lib/libnetgraph/sock.c @@ -71,10 +71,10 @@ NgMkSockNode(const char *name, int *csp, int *dsp) name = NULL; /* Create control socket; this also creates the netgraph node. - If we get an EPROTONOSUPPORT then the socket node type is + If we get an EAFNOSUPPORT then the socket node type is not loaded, so load it and try again. */ if ((cs = socket(AF_NETGRAPH, SOCK_DGRAM, NG_CONTROL)) < 0) { - if (errno == EPROTONOSUPPORT) { + if (errno == EAFNOSUPPORT) { if (kldload(NG_SOCKET_KLD) < 0) { errnosv = errno; if (_gNgDebugLevel >= 1) Reproing the issue was trivial using the ether.bridge example script setup with appropriate interfaces. I have the patch with the netgraph fix attached, along with other potential fixes that needs to be more properly tested. Thanks, -Garrett --e89a8ff2535c7d472104d15bc0b0 Content-Type: application/octet-stream; name="0001-Fix-socket-calls-on-error-post-r243965.patch" Content-Disposition: attachment; filename="0001-Fix-socket-calls-on-error-post-r243965.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_haza2zk10 RnJvbSBjYzZmNzRiMmIyMTlkMjgzZjM0NWViMzE5NjY5NDE0NWMzM2EzODVlIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBHYXJyZXR0IENvb3BlciA8eWFuZWdvbWlAZ21haWwuY29tPgpE YXRlOiBGcmksIDIxIERlYyAyMDEyIDA0OjEwOjA3IC0wODAwClN1YmplY3Q6IFtQQVRDSF0gRml4 IHNvY2tldCBjYWxscyBvbiBlcnJvciBwb3N0LXIyNDM5NjUKClNpZ25lZC1vZmYtYnk6IEdhcnJl dHQgQ29vcGVyIDx5YW5lZ29taUBnbWFpbC5jb20+Ci0tLQogYmluL2RhdGUvbmV0ZGF0ZS5jICAg ICAgIHwgMiArLQogbGliL2xpYm5ldGdyYXBoL3NvY2suYyAgIHwgNCArKy0tCiBzYmluL2hhc3Rk L3BhcnNlLnkgICAgICAgfCAyICstCiBzYmluL2lmY29uZmlnL2FmX25kNi5jICAgfCAyICstCiBz YmluL2lmY29uZmlnL2lmY29uZmlnLmMgfCAyICstCiB1c3Iuc2Jpbi9tdGVzdC9tdGVzdC5jICAg fCA0ICsrLS0KIHVzci5zYmluL25mc2QvbmZzZC5jICAgICB8IDIgKy0KIDcgZmlsZXMgY2hhbmdl ZCwgOSBpbnNlcnRpb25zKCspLCA5IGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL2Jpbi9kYXRl L25ldGRhdGUuYyBiL2Jpbi9kYXRlL25ldGRhdGUuYwppbmRleCBiMDg1YmU0Li5lNTA2ZTZkIDEw MDY0NAotLS0gYS9iaW4vZGF0ZS9uZXRkYXRlLmMKKysrIGIvYmluL2RhdGUvbmV0ZGF0ZS5jCkBA IC04NSw3ICs4NSw3IEBAIG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ic29ja2V0Iik7CiAJCWlw NmZsYWcgPSAwOwogCX0gZWxzZSBpZiAoZ2V0bmV0Y29uZmlnZW50KCJ1ZHA2IikgPT0gTlVMTCB8 fAotLSAKMS44LjAKCg== --e89a8ff2535c7d472104d15bc0b0--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGH67wQhapDDqGjKGgdBwNR7GsJBwTk7Fh7tCuCV4zh7B-Yduw>