No such process (3) when not connected to a network (AF_ROUTE)
up vote
2
down vote
favorite
When I am connected to a network, I can send a struct rt_msghdr*
to the kernel and receive a corresponding route. However, when I disconnect from the network and try to send the same route message header, the socket fails at send()
with errno = ESRCH (3) No such process
.
Generic code: (Testing on MacOS)
int sd = create_socket(AF_ROUTE, IPPROTO_RAW, AF_UNSPEC);
memset(&buffer[0], 0, buffer.size());
struct rt_msghdr* rmh = (struct rt_msghdr*)(&buffer[0]);
rmh->rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);
rmh->rtm_version = RTM_VERSION;
rmh->rtm_type = RTM_GET;
rmh->rtm_addrs = RTA_DST;
rmh->rtm_pid = getpid();
rmh->rtm_seq = 1;
struct sockaddr_in* sa_in = (struct sockaddr_in*)(rmh + 1);
sa_in->sin_len = sizeof(struct sockaddr_in);
sa_in->sin_family = AF_INET;
int status;
if ((status = send(sd, rmh, rmh->rtm_msglen, 0) < 0) {
// process errno
// * issue happens here when not connected to a network
}
// receive kernel response(s)
// process responses
close(sd);
I verified that the process ID (pid) is being set correctly in the header. netstat -nr
returns the default route without issue when not connected to a network. I'm having trouble understanding why this code is dependent on network connectivity.
networking c route bsd
New contributor
add a comment |
up vote
2
down vote
favorite
When I am connected to a network, I can send a struct rt_msghdr*
to the kernel and receive a corresponding route. However, when I disconnect from the network and try to send the same route message header, the socket fails at send()
with errno = ESRCH (3) No such process
.
Generic code: (Testing on MacOS)
int sd = create_socket(AF_ROUTE, IPPROTO_RAW, AF_UNSPEC);
memset(&buffer[0], 0, buffer.size());
struct rt_msghdr* rmh = (struct rt_msghdr*)(&buffer[0]);
rmh->rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);
rmh->rtm_version = RTM_VERSION;
rmh->rtm_type = RTM_GET;
rmh->rtm_addrs = RTA_DST;
rmh->rtm_pid = getpid();
rmh->rtm_seq = 1;
struct sockaddr_in* sa_in = (struct sockaddr_in*)(rmh + 1);
sa_in->sin_len = sizeof(struct sockaddr_in);
sa_in->sin_family = AF_INET;
int status;
if ((status = send(sd, rmh, rmh->rtm_msglen, 0) < 0) {
// process errno
// * issue happens here when not connected to a network
}
// receive kernel response(s)
// process responses
close(sd);
I verified that the process ID (pid) is being set correctly in the header. netstat -nr
returns the default route without issue when not connected to a network. I'm having trouble understanding why this code is dependent on network connectivity.
networking c route bsd
New contributor
Don't have a Mac OS X box to test on, but I'm somewhat surprised netstat shows a default route w/o a network — I'd expect there not to be one (and that the error you're getting means as much). Curious what netstat gives as the default route.
– derobert
Nov 29 at 20:51
@derobert That's reassuring to hear! These are the results of netstat on OSX without a network connectiondefault - fe80::%utun0 - UGcI - utun0
in the format "Destination, Gateway, Flags, Netif Expire"
– TekuConcept
Nov 29 at 21:08
fe80:: is an IPv6 address, but you're asking for IPv4 (AF_INET). So probably you'd get that if you asked for AF_INET6 (and changed to sockaddr_in6, etc.).
– derobert
Nov 29 at 21:13
[BTW: You'll probably find much more knowledge about programming the OSX/BSD APIs on Stack Overflow — you should consider asking there, presuming of course someone else hasn't already asked. ]
– derobert
Nov 29 at 21:38
Okay, I updated my code to try for the IPv6 route if the IPv4 route failed. Still no luck. :( I was about to ask on SO, but figured this was more specific to BSD. I'll ask there and see what I can dig up.
– TekuConcept
Nov 29 at 21:43
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
When I am connected to a network, I can send a struct rt_msghdr*
to the kernel and receive a corresponding route. However, when I disconnect from the network and try to send the same route message header, the socket fails at send()
with errno = ESRCH (3) No such process
.
Generic code: (Testing on MacOS)
int sd = create_socket(AF_ROUTE, IPPROTO_RAW, AF_UNSPEC);
memset(&buffer[0], 0, buffer.size());
struct rt_msghdr* rmh = (struct rt_msghdr*)(&buffer[0]);
rmh->rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);
rmh->rtm_version = RTM_VERSION;
rmh->rtm_type = RTM_GET;
rmh->rtm_addrs = RTA_DST;
rmh->rtm_pid = getpid();
rmh->rtm_seq = 1;
struct sockaddr_in* sa_in = (struct sockaddr_in*)(rmh + 1);
sa_in->sin_len = sizeof(struct sockaddr_in);
sa_in->sin_family = AF_INET;
int status;
if ((status = send(sd, rmh, rmh->rtm_msglen, 0) < 0) {
// process errno
// * issue happens here when not connected to a network
}
// receive kernel response(s)
// process responses
close(sd);
I verified that the process ID (pid) is being set correctly in the header. netstat -nr
returns the default route without issue when not connected to a network. I'm having trouble understanding why this code is dependent on network connectivity.
networking c route bsd
New contributor
When I am connected to a network, I can send a struct rt_msghdr*
to the kernel and receive a corresponding route. However, when I disconnect from the network and try to send the same route message header, the socket fails at send()
with errno = ESRCH (3) No such process
.
Generic code: (Testing on MacOS)
int sd = create_socket(AF_ROUTE, IPPROTO_RAW, AF_UNSPEC);
memset(&buffer[0], 0, buffer.size());
struct rt_msghdr* rmh = (struct rt_msghdr*)(&buffer[0]);
rmh->rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);
rmh->rtm_version = RTM_VERSION;
rmh->rtm_type = RTM_GET;
rmh->rtm_addrs = RTA_DST;
rmh->rtm_pid = getpid();
rmh->rtm_seq = 1;
struct sockaddr_in* sa_in = (struct sockaddr_in*)(rmh + 1);
sa_in->sin_len = sizeof(struct sockaddr_in);
sa_in->sin_family = AF_INET;
int status;
if ((status = send(sd, rmh, rmh->rtm_msglen, 0) < 0) {
// process errno
// * issue happens here when not connected to a network
}
// receive kernel response(s)
// process responses
close(sd);
I verified that the process ID (pid) is being set correctly in the header. netstat -nr
returns the default route without issue when not connected to a network. I'm having trouble understanding why this code is dependent on network connectivity.
networking c route bsd
networking c route bsd
New contributor
New contributor
New contributor
asked Nov 29 at 20:34
TekuConcept
1111
1111
New contributor
New contributor
Don't have a Mac OS X box to test on, but I'm somewhat surprised netstat shows a default route w/o a network — I'd expect there not to be one (and that the error you're getting means as much). Curious what netstat gives as the default route.
– derobert
Nov 29 at 20:51
@derobert That's reassuring to hear! These are the results of netstat on OSX without a network connectiondefault - fe80::%utun0 - UGcI - utun0
in the format "Destination, Gateway, Flags, Netif Expire"
– TekuConcept
Nov 29 at 21:08
fe80:: is an IPv6 address, but you're asking for IPv4 (AF_INET). So probably you'd get that if you asked for AF_INET6 (and changed to sockaddr_in6, etc.).
– derobert
Nov 29 at 21:13
[BTW: You'll probably find much more knowledge about programming the OSX/BSD APIs on Stack Overflow — you should consider asking there, presuming of course someone else hasn't already asked. ]
– derobert
Nov 29 at 21:38
Okay, I updated my code to try for the IPv6 route if the IPv4 route failed. Still no luck. :( I was about to ask on SO, but figured this was more specific to BSD. I'll ask there and see what I can dig up.
– TekuConcept
Nov 29 at 21:43
add a comment |
Don't have a Mac OS X box to test on, but I'm somewhat surprised netstat shows a default route w/o a network — I'd expect there not to be one (and that the error you're getting means as much). Curious what netstat gives as the default route.
– derobert
Nov 29 at 20:51
@derobert That's reassuring to hear! These are the results of netstat on OSX without a network connectiondefault - fe80::%utun0 - UGcI - utun0
in the format "Destination, Gateway, Flags, Netif Expire"
– TekuConcept
Nov 29 at 21:08
fe80:: is an IPv6 address, but you're asking for IPv4 (AF_INET). So probably you'd get that if you asked for AF_INET6 (and changed to sockaddr_in6, etc.).
– derobert
Nov 29 at 21:13
[BTW: You'll probably find much more knowledge about programming the OSX/BSD APIs on Stack Overflow — you should consider asking there, presuming of course someone else hasn't already asked. ]
– derobert
Nov 29 at 21:38
Okay, I updated my code to try for the IPv6 route if the IPv4 route failed. Still no luck. :( I was about to ask on SO, but figured this was more specific to BSD. I'll ask there and see what I can dig up.
– TekuConcept
Nov 29 at 21:43
Don't have a Mac OS X box to test on, but I'm somewhat surprised netstat shows a default route w/o a network — I'd expect there not to be one (and that the error you're getting means as much). Curious what netstat gives as the default route.
– derobert
Nov 29 at 20:51
Don't have a Mac OS X box to test on, but I'm somewhat surprised netstat shows a default route w/o a network — I'd expect there not to be one (and that the error you're getting means as much). Curious what netstat gives as the default route.
– derobert
Nov 29 at 20:51
@derobert That's reassuring to hear! These are the results of netstat on OSX without a network connection
default - fe80::%utun0 - UGcI - utun0
in the format "Destination, Gateway, Flags, Netif Expire"– TekuConcept
Nov 29 at 21:08
@derobert That's reassuring to hear! These are the results of netstat on OSX without a network connection
default - fe80::%utun0 - UGcI - utun0
in the format "Destination, Gateway, Flags, Netif Expire"– TekuConcept
Nov 29 at 21:08
fe80:: is an IPv6 address, but you're asking for IPv4 (AF_INET). So probably you'd get that if you asked for AF_INET6 (and changed to sockaddr_in6, etc.).
– derobert
Nov 29 at 21:13
fe80:: is an IPv6 address, but you're asking for IPv4 (AF_INET). So probably you'd get that if you asked for AF_INET6 (and changed to sockaddr_in6, etc.).
– derobert
Nov 29 at 21:13
[BTW: You'll probably find much more knowledge about programming the OSX/BSD APIs on Stack Overflow — you should consider asking there, presuming of course someone else hasn't already asked. ]
– derobert
Nov 29 at 21:38
[BTW: You'll probably find much more knowledge about programming the OSX/BSD APIs on Stack Overflow — you should consider asking there, presuming of course someone else hasn't already asked. ]
– derobert
Nov 29 at 21:38
Okay, I updated my code to try for the IPv6 route if the IPv4 route failed. Still no luck. :( I was about to ask on SO, but figured this was more specific to BSD. I'll ask there and see what I can dig up.
– TekuConcept
Nov 29 at 21:43
Okay, I updated my code to try for the IPv6 route if the IPv4 route failed. Still no luck. :( I was about to ask on SO, but figured this was more specific to BSD. I'll ask there and see what I can dig up.
– TekuConcept
Nov 29 at 21:43
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
TekuConcept is a new contributor. Be nice, and check out our Code of Conduct.
TekuConcept is a new contributor. Be nice, and check out our Code of Conduct.
TekuConcept is a new contributor. Be nice, and check out our Code of Conduct.
TekuConcept is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485015%2fno-such-process-3-when-not-connected-to-a-network-af-route%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Don't have a Mac OS X box to test on, but I'm somewhat surprised netstat shows a default route w/o a network — I'd expect there not to be one (and that the error you're getting means as much). Curious what netstat gives as the default route.
– derobert
Nov 29 at 20:51
@derobert That's reassuring to hear! These are the results of netstat on OSX without a network connection
default - fe80::%utun0 - UGcI - utun0
in the format "Destination, Gateway, Flags, Netif Expire"– TekuConcept
Nov 29 at 21:08
fe80:: is an IPv6 address, but you're asking for IPv4 (AF_INET). So probably you'd get that if you asked for AF_INET6 (and changed to sockaddr_in6, etc.).
– derobert
Nov 29 at 21:13
[BTW: You'll probably find much more knowledge about programming the OSX/BSD APIs on Stack Overflow — you should consider asking there, presuming of course someone else hasn't already asked. ]
– derobert
Nov 29 at 21:38
Okay, I updated my code to try for the IPv6 route if the IPv4 route failed. Still no luck. :( I was about to ask on SO, but figured this was more specific to BSD. I'll ask there and see what I can dig up.
– TekuConcept
Nov 29 at 21:43