kohler / click

The Click modular router: fast modular packet processing and analysis
Other
735 stars 322 forks source link

Beginner question about write handers for RoundRobinIPMapper #459

Open sarahhercock opened 4 years ago

sarahhercock commented 4 years ago

Hi, I'm new to using click and am attempting to use it to dynamically redirect TCP flows among a few servers.

I have a RoundRobinIPMapper defining patterns for an IPRewriter. It simply rewrites the destination IP to the IP address of one of my servers.

My issue is that I cannot update the configuration of the RoundRobinIPMapper from a controller through a tcp ControlSocket element. I can successfully call write handlers for other elements, but the IP mapper element does not have write permissions, only read.

I would be incredibly grateful if anyone has an idea of steps I can take to solve the problem, thank you in advance!

ahenning commented 4 years ago

If the objective is to solve this in code then a custom version of the element can be made with new write handlers to change the patterns. Maybe also take a look at can_live_reconfigure.

But if the objective is just to simply update element configuration infrequently, then hot reconfigure is an option: "-R, --allow-reconfigure Provide a writable 'hotconfig' handler."

To use this option start click initially with reconfigure enabled: click -R -f ipmapper-test.click

Then the config can updated and hotswapped using the hotconfig write handler. Here is an idiom to replace the live config: perl -e 'print "write hotconfig "; open(my $f, "<", "ipmapper-test.click") ; while (<$f>) { chomp; print $_ . " "; } print "\nquit\n";' | nc localhost 13000

note the hotconfig handler has a default 65K input limit.

sarahhercock commented 4 years ago

Thank you so much, this works well!