- all the patches use temporary option code for v4 and v6 until IANA assigned numbers for draft-ietf-dhc-relay-port. https://tools.ietf.org/html/draft-ietf-dhc-relay-port-05 - for relay patches, the patch allows user to define a non-DHCP port (non-67 for v4, non-547 for v6) in command line with option '-rp'. this is similar to the current option '-p'. the global variable 'uint16_t relay_port' is configured with this '-rp' option. the reasons not using interface based port definition include: - the user defined udp source port is only for upstream interfaces to the servers, but still uses standard dhcp port for downstreams - the relay-agent options are formatted when receiving from a downstream interface, and once formatted it can be sent to multiple upstream servers. thus if we define the relay-port on upstream interfaces, the current code flow does not fit when adding this relay options, and if we define the 'relay-port' on downstream interfaces, it does not make much sense, and it can also be too many interfaces to configure. - this feature mainly is for multiple-instances sharing the same ip address, but have to use relay-port to distinguish the incoming message from upstream server, thus it won't have the case for some server may use port 67/547 but other servers use non-dhcp udp port. - 5 patches, as Thomas suggested in our email exchange. v4 server, v4 relay, v6 server, v6 relay and 4o6 support. (1) patch v4 relay - if '-rp' source port is used for communicating to server, a new bpf filter is defined to accept either port 67 and a user defined udp port. this is to allow DHCP client sending to us using port 67, but the DHCP server sending to us using a non-67 udp port. (2) patch v4 server - if the relay forward message has the relay-agent option of RELAY-PORT, then use the udp port from the packet->client_port when sending relay reply message to the relay agent (3) patch v6 relay - same as in v4 relay, the parameter '-rp' is used for user to define an non-547 UDP source port. - in normal v6 relay, it only needs to setup one v6 socket on the relay, which defines the source udp port of 547. in this relay-port feature, if the relay-port is defined, the relay needs to setup two sockets, one for the udp port of 547 in order to continue receiving messages from dhcp client or downstream relay; the other for the non-dhcp udp port for dhcp server to send to us, or for the upstream relay agent when sending relay-reply message to us. - in this patch, in 'discover_interfaces', instead of finding the first interface and breaking out from the loop, it looks for an upstream interface and a downstream interface. we break out of the loop if we have found one upstream and one downstream interfaces. - in if_regster6, it modifies the code, such that if the 'relay-port' is defined, as described above finding the 'upstream' and 'downstream' two interfaces, we need to assign the two interfaces using different socket functions. The 'downstream' interface section is the same as the normal code, but the upstream interface will have the 'relay_port_v6_socket' function assigned for the socket. - the v6 options has a 'downstream source port' field, which is used to record a downstream relay-agent if using a non-547 UDP port. - If the local relay (this process) uses a non-547 udp port, or our 'downstream' relay-agent uses a non-547 udp port, this relay when sending the relay-forw message to upstream, will include the Relay Source Port option in the message. - when receiving from server or an upstream relay agent the relay-reply message, and if there is the Relay Source Port option in the message, and also if the 'downstream source port' value is non-zero, then this process needs to use this value as the udp destination for the downstream relay-agent when sending the relay-reply message. (4) patch server v6 - server has to copy back the 'Relay Source Port' option when sending back the relay-reply message. and If the relay options has this 'Relay Source Port' option, it uses the packet->client_port when sending back the relay-reply message to the relay agent.