Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pimd does not work in background under FreeBSD #33

Closed
skif-kiev opened this issue Apr 14, 2014 · 1 comment
Closed

pimd does not work in background under FreeBSD #33

skif-kiev opened this issue Apr 14, 2014 · 1 comment

Comments

@skif-kiev
Copy link

FreeBSD 9.2-RELEASE amd64
pimd 2.2.0-alpha1

Being started without --debug and --foreground options pimd cant determine bootstrap router so doesn't send RP advertises. The reason is that we call pid=getpid() in routesock.c and use that value later to determine the valid message from routing socket.
But between those operations we do fork() in main.c to daemonize pimd, so it gets new process ID that is different from pid. After that rtm.rtm_pid != pid becomes always true and k_req_incoming() always returns FALSE.

The patch, probably not optimal, follows.
It moves pid determinition from init_routesock() to k_req_incoming().

--- routesock.c 2014-04-13 12:56:38.000000000 +0300
+++ routesock.c 2014-04-14 23:19:34.000000000 +0300
@@ -97,8 +97,6 @@
     int on = 0;
 #endif

-    pid = getpid();
-
     routing_socket = socket(PF_ROUTE, SOCK_RAW, 0);
     if (routing_socket < 0) {
        logit(LOG_ERR, errno, "Failed creating routing socket");
@@ -213,6 +211,8 @@
        return FALSE;
     }

+    pid = getpid();
+
     while (1) {
        rlen = read(routing_socket, &m_rtmsg, sizeof(m_rtmsg));
        if (rlen < 0) {
@troglobit
Copy link
Owner

Hi, sorry for the late reply!

This looks great. Post a git pull request and I'll merge it immediately, or you can wait for my next round of manual merges.

troglobit added a commit that referenced this issue Sep 28, 2014
skif-kiev commented on 14 Apr:
> Being started without --debug and --foreground options pimd cant
> determine bootstrap router so doesn't send RP advertises. The reason
> is that we call `pid = getpid()` in routesock.c and use that value
> later to determine the valid message from routing socket.
>
> But between those operations we do `fork()` in main.c to daemonize
> pimd, so it gets new process ID that is different from pid. After that
> `rtm.rtm_pid != pid` becomes always true and `k_req_incoming()` always
> returns FALSE.

Signed-off-by: Joachim Nilsson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants