aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorAkhil Goyal <akhil.goyal@freescale.com>2016-04-21 23:03:18 +0530
committerMaxim Uvarov <maxim.uvarov@linaro.org>2016-04-25 11:40:14 +0300
commit8e8c5d7a1ecc40bcd6a5e469d1e57df704bd78df (patch)
tree4b96d2c3f80d12fbe8f50ac33c3d43a7ff22d0bb /example
parent9b5192b36717e3c9fbdcf644e08cf5f22d07689b (diff)
example/ipsec: crash with invalid route parameters
If invalid interface is passed in route config parameters, then the application crashes. So Matching the entered interface with the parameters configured in -i parameters. Signed-off-by: Akhil Goyal <akhil.goyal@freescale.com> Reviewed-by: Nikhil.agarwal@linaro.org Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'example')
-rw-r--r--example/ipsec/odp_ipsec.c3
-rw-r--r--example/ipsec/odp_ipsec_fwd_db.c15
-rw-r--r--example/ipsec/odp_ipsec_fwd_db.h6
3 files changed, 20 insertions, 4 deletions
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 05563071d..e75db61d4 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1457,7 +1457,8 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
break;
case 'r':
- rc = create_fwd_db_entry(optarg);
+ rc = create_fwd_db_entry(optarg, appl_args->if_names,
+ appl_args->if_count);
break;
case 'p':
diff --git a/example/ipsec/odp_ipsec_fwd_db.c b/example/ipsec/odp_ipsec_fwd_db.c
index 7b0bc08b4..e1f638461 100644
--- a/example/ipsec/odp_ipsec_fwd_db.c
+++ b/example/ipsec/odp_ipsec_fwd_db.c
@@ -39,9 +39,9 @@ void init_fwd_db(void)
memset(fwd_db, 0, sizeof(*fwd_db));
}
-int create_fwd_db_entry(char *input)
+int create_fwd_db_entry(char *input, char **if_names, int if_count)
{
- int pos = 0;
+ int pos = 0, i, match = 0;
char *local;
char *str;
char *save;
@@ -76,6 +76,17 @@ int create_fwd_db_entry(char *input)
case 1:
strncpy(entry->oif, token, OIF_LEN - 1);
entry->oif[OIF_LEN - 1] = 0;
+ for (i = 0; i < if_count; i++) {
+ if (!strcmp(if_names[i], entry->oif)) {
+ match = 1;
+ break;
+ }
+ }
+ if (!match) {
+ printf("ERROR: interface name not correct for route\n");
+ free(local);
+ return -1;
+ }
break;
case 2:
parse_mac_string(token, entry->dst_mac);
diff --git a/example/ipsec/odp_ipsec_fwd_db.h b/example/ipsec/odp_ipsec_fwd_db.h
index 094253e32..748ae048e 100644
--- a/example/ipsec/odp_ipsec_fwd_db.h
+++ b/example/ipsec/odp_ipsec_fwd_db.h
@@ -51,9 +51,13 @@ void init_fwd_db(void);
*
* @param input Pointer to string describing route
*
+ * @param if_names Array of Name of the interfaces available
+ *
+ * @param if_count number of interfaces in if_names array
+ *
* @return 0 if successful else -1
*/
-int create_fwd_db_entry(char *input);
+int create_fwd_db_entry(char *input, char **if_names, int if_count);
/**
* Scan FWD DB entries and resolve output queue and source MAC address