From 8a4fb0ee19c021abf2e390810dfd70272b7704f6 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Fri, 5 Jul 2024 17:22:27 -0700 Subject: [PATCH] Management framework: augment deployed configs with instance IP addresses The controller learns IP addresses from agents that peer with it, but that information has so far gotten lost when resulting configs get pushed out to the agents. This makes these updates include that information. --- .../frameworks/management/controller/main.zeek | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/policy/frameworks/management/controller/main.zeek b/scripts/policy/frameworks/management/controller/main.zeek index 455f2dc6b3..fd7df8343d 100644 --- a/scripts/policy/frameworks/management/controller/main.zeek +++ b/scripts/policy/frameworks/management/controller/main.zeek @@ -186,6 +186,24 @@ global g_configs: table[ConfigState] of Management::Configuration function config_deploy_to_agents(config: Management::Configuration, req: Management::Request::Request) { + # Make any final changes to the configuration we send off. + + # If needed, fill in agent IP address info as learned from their peerings. + # XXX this will need revisiting when we support host names. + local instances: set[Management::Instance]; + + for ( inst in config$instances ) + { + if ( inst$name in g_instances_known + && inst$host == 0.0.0.0 + && g_instances_known[inst$name]$host != 0.0.0.0 ) + inst$host = g_instances_known[inst$name]$host; + + add instances[inst]; + } + + config$instances = instances; + for ( name in g_instances ) { if ( name !in g_instances_ready )