Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to ask about dhcreay running mechanism. We can run dhcrelay with two command, then it will run as 2 process

dhcrelay -i eth3 172.16.17.3
dhcrelay -i eth1 172.16.17.5

#ps ax | grep dhcre
26464 ?        Ss     0:00 /usr/sbin/dhcrelay -i eth3 172.16.17.3
26465 ?        Ss     0:00 /usr/sbin/dhcrelay -i eth1 172.16.17.5

or with one single command, in other words single process

dhcrelay -i eth3 -i eth1 172.16.17.3 172.16.17.5

#ps ax | grep dhcre
28127 ?        Ss     0:00 /usr/sbin/dhcrelay -i eth1 -i eth3 172.16.17.3 172.16.17.5

I wondered if there is any technical difference between these two ways except the process count?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted
+50

In looking through the source code, there are a couple of things that jump out that would seem to be impacted by running a single command vs. multiple commands.

First this comment in dispatch.c:

/*
 * Wait for packets to come in using poll().  When a packet comes in,
 * call receive_packet to receive the packet and possibly strip hardware
 * addressing information from it, and then call through the
 * bootp_packet_handler hook to try to do something with it.
 */

It would appear that dhcrelay.c makes use of a polling architecture. This one looks to make use of a timeout (time based) when polling one of the interfaces (for example: -i eth0 or -i eth1).

This would seem to indicate that there is some potential for blocking for one interface while the other is being polled.

Another snippet, this time within the dispatch() function, it's polling one of the specified interfaces:

/* Wait for a packet or a timeout... XXX */
count = poll(fds, nfds, to_msec);

After the poll function above either times out or receives a packet dhcrelay moves on to the "next" interface:

    /* Get the current time... */
    time(&cur_time);

    i = 0;
    for (l = protocols; l; l = l->next) {
      struct interface_info *ip = l->local;

      if ((fds[i].revents & (POLLIN | POLLHUP))) {
        fds[i].revents = 0;
        if (ip && (l->handler != got_one ||
            !ip->dead))
          (*(l->handler))(l);
        if (interfaces_invalidated)
          break;
      }
      i++;
    }
    interfaces_invalidated = 0;
  } while (1);

Notice that the entire dispatch contains a while(1) loop.

So what does this all mean?

I would say that if you have a heavily trafficked network with a lot of hosts and your DHCP leases are relatively short, then you may want to consider running 2 instances of dchrelay.

If however, your network is relatively small and your DHCP lease timeouts are relatively long, then running a single instance should be fine.

Some additional things to consider

  • Running 2 instances allows you to maintain separate log files for each.
  • Running 2 instances allows one relayer to be restarted without impacting the other.
share|improve this answer
    
I asked this question because I want to send requests from specific interface to specific server. So, according to example in my question, when I run as multiple process, are requests that coming from eth1 relayed to 172.16.17.3 ? or vice versa ? –  ibrahim Jan 24 '13 at 11:11
    
BTW I believe you'll need to list both the interface that packets will come in/out from the client, and the interface that packets will come in/out from the DHCP server. Given this your single command may not even be an option. –  slm Jan 24 '13 at 13:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.