summaryrefslogtreecommitdiffstats
path: root/plugins/snat-plugin
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-11-10 14:22:49 -0500
committerDamjan Marion <dmarion.lists@gmail.com>2016-11-21 18:11:41 +0000
commit557d128b68a1213e056f5eed9fe6f230ca3f3144 (patch)
tree6b31ac462efacf3f6937788c9b7af1420497c9fc /plugins/snat-plugin
parentfca670b0ec9f74aa977fe479a5517ad6367ee898 (diff)
Add client-side msg_name_and_crc -> msg_index table
vppapigen now generates per-message crcs. Verified that whitespace and real changes in message A don't change the crc for message B, etc. Fixed the sample and flowperpkt plugins to participate. Others need the same treatment. They don't build due to python/java language binding build issues. To use the scheme: Client connects as usual. Then call: u32 vl_api_get_msg_index(char * name_and_crc) name_and_crc is a string like: "flowperpkt_tx_interface_add_del_753301f3", aka the message name with _%08x <expected crc> appended. Try these vpp-api-test commands to play with it: vat# dump_msg_api_table <snip> [366]: punt_reply_cca27fbe [367]: ipsec_spd_dump_5e9ae88e [368]: ipsec_spd_details_6f7821b0 [369]: sample_macswap_enable_disable_0f2813e2 [370]: sample_macswap_enable_disable_reply_476738e5 [371]: flowperpkt_tx_interface_add_del_753301f3 [372]: flowperpkt_tx_interface_add_del_reply_d47e6e0b vat# get_msg_id sample_macswap_enable_disable_reply_476738e5 'sample_macswap_enable_disable_reply_476738e5' has message index 370 vat# get_msg_id sample_macswap_enable_disable_reply_476738e3 'sample_macswap_enable_disable_reply_476738e3' not found CRCs may vary, etc. vppapigen is used to build a set of JSON representations of each API file from vpp-api/Makefile.am and that is in turn used by each language binding (Java, Python, Lua). Change-Id: I3d64582e779dac5f20cddec79c562c288d8fd9c6 Signed-off-by: Dave Barach <dave@barachs.net> Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'plugins/snat-plugin')
-rw-r--r--plugins/snat-plugin/Makefile.am7
-rw-r--r--plugins/snat-plugin/snat/snat.c17
2 files changed, 21 insertions, 3 deletions
diff --git a/plugins/snat-plugin/Makefile.am b/plugins/snat-plugin/Makefile.am
index 9f41193a708..0a0fff86486 100644
--- a/plugins/snat-plugin/Makefile.am
+++ b/plugins/snat-plugin/Makefile.am
@@ -39,8 +39,8 @@ SUFFIXES = .api.h .api
%.py: %.api
$(info Creating Python binding for $@)
- $(CC) $(CPPFLAGS) -E -P -C -x c $< \
- | vppapigen --input - --python - \
+ $(CC) $(CPPFLAGS) -E -P -C -x c $< \
+ | vppapigen --input - --python - \
| pyvppapigen.py --input - > $@
pyapidir = ${prefix}/vpp_papi_plugins
@@ -59,7 +59,8 @@ install-data-hook:
@(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES))
@(cd $(vppapitestpluginsdir) && $(RM) $(vppapitestplugins_LTLIBRARIES))
-
+apidir = $(prefix)/snat
+api_DATA = snat/snat.api
#
# Java code generation
diff --git a/plugins/snat-plugin/snat/snat.c b/plugins/snat-plugin/snat/snat.c
index 66c03817ca0..2956e24f054 100644
--- a/plugins/snat-plugin/snat/snat.c
+++ b/plugins/snat-plugin/snat/snat.c
@@ -955,6 +955,19 @@ snat_plugin_api_hookup (vlib_main_t *vm)
return 0;
}
+#define vl_msg_name_crc_list
+#include <snat/snat_all_api_h.h>
+#undef vl_msg_name_crc_list
+
+static void
+setup_message_id_table (snat_main_t * sm, api_main_t * am)
+{
+#define _(id,n,crc) \
+ vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base);
+ foreach_vl_msg_name_crc_snat;
+#undef _
+}
+
static void plugin_custom_dump_configure (snat_main_t * sm)
{
#define _(n,f) sm->api_main->msg_print_handlers \
@@ -985,6 +998,10 @@ static clib_error_t * snat_init (vlib_main_t * vm)
sm->api_main = &api_main;
error = snat_plugin_api_hookup (vm);
+
+ /* Add our API messages to the global name_crc hash table */
+ setup_message_id_table (sm, &api_main);
+
plugin_custom_dump_configure (sm);
vec_free(name);
ace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

  # Pick the right distro and bootstrap, default is ubuntu1604
  distro = ( ENV['VPP_VAGRANT_DISTRO'] || "ubuntu1604")
  if distro == 'centos7'
    config.vm.box = "centos/7"
    config.vm.box_version = "1708.01"
    config.ssh.insert_key = false
  else
    config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
  end
  config.vm.box_check_update = false

  config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"update.sh")
  config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/vpp vagrant"

  # Create VCL client and server VM's
  config.vm.define "vcl-server" do |server|
    server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"vcl_test.sh"), :args => "/vpp vagrant vcl-server"
  end
  config.vm.define "vcl-client" do |client|
    client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"vcl_test.sh"), :args => "/vpp vagrant vcl-client"
  end
  
  # Add .gnupg dir in so folks can sign patches
  # Note, as gnupg puts socket files in that dir, we have
  # to be cautious and make sure we are dealing with a plain file
  homedir = File.expand_path("~/")
  Dir["#{homedir}/.gnupg/**/*"].each do |fname|
    if File.file?(fname)
      destname = fname.sub(Regexp.escape("#{homedir}/"),'')
      config.vm.provision "file", source: fname, destination: destname
    end
  end

  # Copy in the .gitconfig if it exists
  if File.file?(File.expand_path("~/.gitconfig"))
    config.vm.provision  "file", source: "~/.gitconfig", destination: ".gitconfig"
  end

  # vagrant-cachier caches apt/yum etc to speed subsequent
  # vagrant up
  # to enable, run
  # vagrant plugin install vagrant-cachier
  #
  if Vagrant.has_plugin?("vagrant-cachier")
    config.cache.scope = :box
  end

  # Define some physical ports for your VMs to be used by DPDK
  nics = (ENV['VPP_VAGRANT_NICS'] || "2").to_i(10)
  for i in 1..nics
    config.vm.network "private_network", type: "dhcp"
  end

  # use http proxy if avaiable
  if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
   config.proxy.http     = ENV['http_proxy']
   config.proxy.https    = ENV['https_proxy']
   config.proxy.no_proxy = "localhost,127.0.0.1"
  end

  vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
  vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096)

  config.ssh.forward_agent = true
  config.ssh.forward_x11 = true

  config.vm.provider "virtualbox" do |vb|
      vb.customize ["modifyvm", :id, "--ioapic", "on"]
      vb.memory = "#{vmram}"
      vb.cpus = "#{vmcpu}"

      # rsync the vpp directory if provision hasn't happened yet
      unless File.exist? (".vagrant/machines/client/virtualbox/action_provision")
        config.vm.synced_folder "../../", "/vpp", type: "rsync",
         rsync__auto: false,
         rsync__exclude: [
          "build-root/build*/",
          "build-root/install*/",
          "build-root/images*/",
          "build-root/*.deb",
          "build-root/*.rpm",
          "build-root/*.changes",
          "build-root/python",
          "build-root/deb/debian/*.dkms",
          "build-root/deb/debian/*.install",
          "build-root/deb/debian/changes",
          "build-root/tools"]
      end

      #support for the SSE4.x instruction is required in some versions of VB.
      vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
      vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
  end
  config.vm.provider "vmware_fusion" do |fusion,override|
    fusion.vmx["memsize"] = "#{vmram}"
    fusion.vmx["numvcpus"] = "#{vmcpu}"
  end
  config.vm.provider "libvirt" do |lv|
    lv.memory = "#{vmram}"
    lv.cpus = "#{vmcpu}"
  end
  config.vm.provider "vmware_workstation" do |vws,override|
    vws.vmx["memsize"] = "#{vmram}"
    vws.vmx["numvcpus"] = "#{vmcpu}"
  end  
end