aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs/vCPE/vpp-option-82-for-vbrg/src
diff options
context:
space:
mode:
authorItohan <itohan.ukponmwan@intel.com>2017-11-17 09:26:51 -0800
committerItohan <itohan.ukponmwan@intel.com>2017-11-17 20:23:58 -0800
commitea980674dcc0be590604cf69c83a793cd1796d13 (patch)
tree1d19df01d803f402d187d7c42072abf8038dc0a1 /vnfs/vCPE/vpp-option-82-for-vbrg/src
parent640071642bb49c3aea5f4decedc213e5974f3a1a (diff)
Fixed bug in vbrg vpp snat patch
Modified script to close files after use Modified script to call fgets only if file is not null Issue-ID: INT-63 Change-Id: I61519f9c248dde8ae44f148cb4c1cc594615ea7c Signed-off-by: Itohan <itohan.ukponmwan@intel.com>
Diffstat (limited to 'vnfs/vCPE/vpp-option-82-for-vbrg/src')
-rwxr-xr-xvnfs/vCPE/vpp-option-82-for-vbrg/src/patches/VPP-Add-Option82-Nat-Filter-For-vBRG.patch77
1 files changed, 45 insertions, 32 deletions
diff --git a/vnfs/vCPE/vpp-option-82-for-vbrg/src/patches/VPP-Add-Option82-Nat-Filter-For-vBRG.patch b/vnfs/vCPE/vpp-option-82-for-vbrg/src/patches/VPP-Add-Option82-Nat-Filter-For-vBRG.patch
index 73b19150..899ff25a 100755
--- a/vnfs/vCPE/vpp-option-82-for-vbrg/src/patches/VPP-Add-Option82-Nat-Filter-For-vBRG.patch
+++ b/vnfs/vCPE/vpp-option-82-for-vbrg/src/patches/VPP-Add-Option82-Nat-Filter-For-vBRG.patch
@@ -1,5 +1,11 @@
+commit 43028d14c3bfb09c582caa8b610e447118fb71c1
+Author: Itohan Ukponmwan <itohan.ukponmwan@intel.com>
+Date: Fri Nov 17 21:18:23 2017 +0000
+
+ Modified out2in.c and client.c
+
diff --git a/src/plugins/snat/out2in.c b/src/plugins/snat/out2in.c
-index 5c12b47..f7c7caf 100644
+index 7de85eb..e2e6cec 100644
--- a/src/plugins/snat/out2in.c
+++ b/src/plugins/snat/out2in.c
@@ -1,3 +1,4 @@
@@ -7,37 +13,36 @@ index 5c12b47..f7c7caf 100644
/*
* Copyright (c) 2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
-@@ -658,6 +659,26 @@ snat_out2in_node_fn (vlib_main_t * vm,
+@@ -648,6 +649,25 @@ snat_out2in_node_fn (vlib_main_t * vm,
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
-
+
+ //FOR BRG
+ ip4_address_t * sdnc_addr = malloc(4);
+ char line_input[128];
+ char * path = "/opt/config/ip.txt";
+ FILE * f = fopen(path, "r");
-+ if (f == NULL)
-+ printf("cannot open such file\n");
-+
-+ while (fgets(line_input, 128, f) != NULL){
-+ if (!strcmp(strtok(line_input, " "),"sdnc_ip:")){
-+ char * ip = strtok(NULL, " ");
-+ char * num = strtok(ip, ".");
-+ sdnc_addr->data[0] = atoi(num);
-+ for (int i = 1; i < 4; i ++){
-+ num = strtok(NULL, ".");
-+ sdnc_addr->data[i] = atoi(num);
++ if (f != NULL){
++ while (fgets(line_input, 128, f) != NULL){
++ if (!strcmp(strtok(line_input, " "),"sdnc_ip:")){
++ char * ip = strtok(NULL, " ");
++ char * num = strtok(ip, ".");
++ sdnc_addr->data[0] = atoi(num);
++ for (int i = 1; i < 4; i ++){
++ num = strtok(NULL, ".");
++ sdnc_addr->data[i] = atoi(num);
++ }
+ }
+ }
++ fclose(f);
+ }
-+
while (n_left_from > 0)
{
u32 n_left_to_next;
-@@ -733,6 +754,13 @@ snat_out2in_node_fn (vlib_main_t * vm,
-
+@@ -723,6 +743,13 @@ snat_out2in_node_fn (vlib_main_t * vm,
+
proto0 = ip_proto_to_snat_proto (ip0->protocol);
-
+
+ //for BRG
+ if (PREDICT_TRUE (ip0->src_address.data_u32 != sdnc_addr->data_u32))
+ {
@@ -46,12 +51,12 @@ index 5c12b47..f7c7caf 100644
+ }
+
if (PREDICT_FALSE (proto0 == ~0))
- {
- snat_out2in_unknown_proto(sm, b0, ip0, rx_fib_index0);
-@@ -871,6 +899,13 @@ snat_out2in_node_fn (vlib_main_t * vm,
-
+ goto trace0;
+
+@@ -858,6 +885,13 @@ snat_out2in_node_fn (vlib_main_t * vm,
+
proto1 = ip_proto_to_snat_proto (ip1->protocol);
-
+
+ //for BRG
+ if (PREDICT_TRUE (ip1->src_address.data_u32 != sdnc_addr->data_u32))
+ {
@@ -60,10 +65,10 @@ index 5c12b47..f7c7caf 100644
+ }
+
if (PREDICT_FALSE (proto1 == ~0))
- {
- snat_out2in_unknown_proto(sm, b1, ip1, rx_fib_index1);
-@@ -1033,6 +1068,13 @@ snat_out2in_node_fn (vlib_main_t * vm,
-
+ goto trace1;
+
+@@ -1017,6 +1051,13 @@ snat_out2in_node_fn (vlib_main_t * vm,
+
proto0 = ip_proto_to_snat_proto (ip0->protocol);
+ //for BRG
@@ -74,16 +79,24 @@ index 5c12b47..f7c7caf 100644
+ }
+
if (PREDICT_FALSE (proto0 == ~0))
- {
- snat_out2in_unknown_proto(sm, b0, ip0, rx_fib_index0);
+ goto trace00;
+
+@@ -1153,6 +1194,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
+ vlib_node_increment_counter (vm, snat_out2in_node.index,
+ SNAT_OUT2IN_ERROR_OUT2IN_PACKETS,
+ pkts_processed);
++ free(sdnc_addr);
+ return frame->n_vectors;
+ }
+
diff --git a/src/vnet/dhcp/client.c b/src/vnet/dhcp/client.c
-index 014f17a..296e1a7 100644
+index 7c3f7f6..41bc2c7 100644
--- a/src/vnet/dhcp/client.c
+++ b/src/vnet/dhcp/client.c
-@@ -427,6 +427,16 @@ send_dhcp_pkt (dhcp_client_main_t * dcm, dhcp_client_t * c,
+@@ -426,6 +426,16 @@ send_dhcp_pkt (dhcp_client_main_t * dcm, dhcp_client_t * c,
clib_memcpy (o->data, c->option_55_data, vec_len(c->option_55_data));
o = (dhcp_option_t *) (((uword) o) + (o->length + 2));
-
+
+ /*send option 82*/
+ u8 sub2_len = vec_len(hw->hw_address);
+ o->option = 82;