[PATCH] Add RPC support for DHCPv4 client
Cherry-picked from
https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/
master/net-misc/dhcpcd/files/patches/dhcpcd-6.8.2-Add-RPC-support-for-
DHCPv4-client.patch.
Define a RPC interface for the daemon to interact with other
applications (command execution and status update), and integrate
it with the DHCPv4 client. Default to stub implementation for now
until new RPC mechanism is implemented and enabled.
Also add a new compiler flag "PASSIVE_MODE" which will be enabled
when a RPC mechanism is enabled (e.g. DBus). This compiler flag
will prevent the daemon from modifying system configurations
(e.g. routing table, interface address). The idea is that when
RPC is enabled, the daemon will provide configurations through
RPC, and the remote application will be the one responsible for
modifying system configurations.
Integration with DHCPv6 client will be added in the future.
BUG: 22956197
Change-Id: I7147d13e2cfab5c209c1ab862f33ef9d1b1dddaf
Reviewed-on: https://chromium-review.googlesource.com/208835
Review URL: http://codereview.chromium.org/3061018
diff --git a/dhcpcd.c b/dhcpcd.c
index 763e06f..a486ac2 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -63,6 +63,7 @@
#include "ipv4.h"
#include "ipv6.h"
#include "ipv6nd.h"
+#include "rpc-interface.h"
#include "script.h"
#ifdef USE_SIGNALS
@@ -1777,6 +1778,12 @@
(DHCPCD_MASTER | DHCPCD_DEV))
dev_start(&ctx);
+ if (rpc_init(&ctx) == -1) {
+ /* NB: rpc_init generates a syslog msg */
+ exit(EXIT_FAILURE);
+ }
+ rpc_signal_status("Init");
+
ctx.ifaces = if_discover(&ctx, ctx.ifc, ctx.ifv);
if (ctx.ifaces == NULL) {
logger(&ctx, LOG_ERR, "if_discover: %m");