[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT/CLICK PATCH 09/11] support for loading click configs



Hi Felipe,

since I'm doing a v2 anyway, I can give that a shot.

On 6/4/19 4:16 PM, Felipe Huici wrote:
Hi Florian,

This patch looks good. It might be clearer if the commit message said the 
initrd file should be a plain text file (unlike include/static_config.h), but I 
can fix that on upstream.

Thanks,

-- Felipe

Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>


On 02.06.19, 07:53, "Florian Schmidt" <Florian.Schmidt@xxxxxxxxx> wrote:

     The expected way is to provide a config file as initrd. If no initrd is
     provided, click will fall back to a static, compiled-in config that
     replies to pings.
Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
     ---
      click.cc                | 37 ++++++++++++++++++++++++++++++++-----
      include/static_config.h | 22 ++++++++++++++++++++++
      2 files changed, 54 insertions(+), 5 deletions(-)
      create mode 100644 include/static_config.h
diff --git a/click.cc b/click.cc
     index a3bfba8..85a938b 100644
     --- a/click.cc
     +++ b/click.cc
     @@ -52,11 +52,14 @@ extern "C"{
      #include <click/straccum.hh>
      #include <click/driver.hh>
+#include <static_config.h>
     +
      #include <uk/sched.h>
      #include <uk/thread.h>
     +#include <uk/netdev.h>
     +#include <uk/plat/memory.h>
int click_nthreads = 1;
     -
      void *__dso_handle = NULL;
#define NLOG(fmt, ...)
     @@ -119,6 +122,32 @@ read_config(u_int rid = 0)
      static ErrorHandler *errh;
      static Master master(1);
+static String *
     +get_config()
     +{
     +  String *cfg;
     +  struct ukplat_memregion_desc img;
     +  char *cstr;
     +  size_t cstr_len;
     +
     +  /* First, try initrd */
     +  if (ukplat_memregion_find_initrd0(&img) >= 0) {
     +          cstr = (char *)img.base;
     +          cstr_len = img.len;
     +  } else {
     +          /* If we can't find a config: use a fallback one statically
     +           * compiled in.
     +           */
     +          uk_pr_warn("Could not find a config, using standard config!\n");
     +          cstr = CONFIGSTRING;
     +          cstr_len = strlen(CONFIGSTRING);
     +  }
     +  cfg = new String(cstr, cstr_len);
     +  printf("Received config (length %d):\n", cfg->length());
     +  printf("%s\n", cfg->c_str());
     +  return cfg;
     +}
     +
      struct router_instance {
        Router *r;
        u_int f_stop;
     @@ -127,9 +156,8 @@ struct router_instance {
      void
      router_thread(void *thread_data)
      {
     -  u_int *rid = (u_int*) thread_data;
     -  String *config = new String; //read_config(*rid);
     -  struct router_instance *ri = &router_list[*rid];
     +  struct router_instance *ri = &router_list[(unsigned long)thread_data];
     +  String *config = get_config();
ri->r = click_read_router(*config, true, errh, false, &master);
        if (ri->r->initialize(errh) < 0) {
     @@ -150,7 +178,6 @@ router_thread(void *thread_data)
LOG("Master/driver stopped, closing router_thread");
        free(config);
     -  free(rid);
      }
void
     diff --git a/include/static_config.h b/include/static_config.h
     new file mode 100644
     index 0000000..85c5d12
     --- /dev/null
     +++ b/include/static_config.h
     @@ -0,0 +1,22 @@
     +static char CONFIGSTRING[] = "    define($IP 10.0.10.123);\n\
     +    define($MAC0 11:22:33:44:55:66);\n\
     +\n\
     +    source :: FromDevice;\n\
     +    sink   :: ToDevice;\n\
     +    // classifies packets \n\
     +    c :: Classifier(\n\
     +        12/0806 20/0001, // ARP Requests goes to output 0\n\
     +        12/0806 20/0002, // ARP Replies to output 1\n\
     +        12/0800 14/45 34/08, // ICMP Requests to output 2\n\
     +        -); // without a match to output 3\n\
     +\n\
     +    arpq :: ARPQuerier($IP, $MAC0);\n\
     +    arpr :: ARPResponder($IP $MAC0);\n\
     +\n\
     +    source -> c;\n\
     +    c[0] -> CheckARPHeader(14) -> ARPPrint -> arpr -> ARPPrint -> sink;\n\
     +    c[1] -> [1]arpq;\n\
     +    Idle -> [0]arpq;\n\
     +    arpq -> sink;\n\
     +    c[2] -> CheckIPHeader(14) -> IPPrint -> ICMPPingResponder() -> 
EtherMirror() -> IPPrint -> sink;\n\
     +    c[3] -> Discard;";
     --
     2.21.0

--
Dr. Florian Schmidt
フローリアン・シュミット
Research Scientist,
Systems and Machine Learning Group
NEC Laboratories Europe
Kurfürsten-Anlage 36, D-69115 Heidelberg
Tel.     +49 (0)6221 4342-265
Fax:     +49 (0)6221 4342-155
e-mail:  florian.schmidt@xxxxxxxxx
============================================================
Registered at Amtsgericht Mannheim, Germany, HRB728558

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.