Developing lightweight computation at the DSG edge

Commit 623a67f2 authored by Agustí Moll Garcia's avatar Agustí Moll Garcia
Browse files

Added in bmx6 the option to parametritze the MTU in tunOut

parent 2ec91833
diff --git a/hna.c b/hna.c
index 74cbdd5..3583e86 100644
--- a/hna.c
+++ b/hna.c
@@ -996,8 +996,11 @@ void set_tun_net(struct tun_search_node *sn)
struct tunnel_node_out *tun = best_tnn->key.tun;
- if (!tun->upIfIdx && configure_tunnel_out(ADD, tun->key.on, tun) == SUCCESS)
+ if (!tun->upIfIdx && configure_tunnel_out(ADD, tun->key.on, tun) == SUCCESS){
ipaddr(ADD, tun->upIfIdx, AF_INET6, &tun->localIp, 128, YES /*deprecated*/);
+ change_mtu(tun->name.str, tsn->mtu);
+ dbgf_track(DBGT_INFO, "Set MTU from %s as %d",tun->name.str, tsn->mtu);
+ }
if (tun->upIfIdx) {
if (tsn->family == AF_INET && !is_ip_set(&tun->src4Ip)) {
@@ -1598,6 +1601,13 @@ int32_t opt_tun_search(uint8_t cmd, uint8_t _save, struct opt_type *opt, struct
} else if (cmd == OPT_APPLY && tsn) {
memset(&tsn->global_id.pkid, 0, GLOBAL_ID_PKID_LEN);
}
+ } else if (!strcmp(c->opt->name, ARG_TUN_SEARCH_MTU)) {
+ if (c->val) {
+ uint16_t mtuVal = c->val ? strtol(c->val, NULL, 10) : DEF_TUN_SEARCH_MTU;
+ if (cmd == OPT_APPLY && tsn)
+ tsn->mtu = mtuVal;
+ }
+
}
}
}
@@ -1990,7 +2000,9 @@ struct opt_type hna_options[]= {
{ODI,ARG_TUN_SEARCH_NAME,ARG_TUN_SEARCH_PKID,0,5,1,A_CS1,A_ADM,A_DYI,A_CFA,A_ANY,0, 0, 0, 0,0, opt_tun_search,
ARG_SHA2_FORM, "specify pkid of remote tunnel endpoint"},
{ODI,ARG_TUN_SEARCH_NAME,ARG_TUN_SEARCH_IPMETRIC,0,5,1,A_CS1,A_ADM,A_DYI,A_CFA,A_ANY,0, 0, MAX_TUN_SEARCH_IPMETRIC,0,0, opt_tun_search,
- ARG_VALUE_FORM, "specify ip metric for local routing table entries"}
+ ARG_VALUE_FORM, "specify ip metric for local routing table entries"},
+ {ODI,ARG_TUN_SEARCH_NAME,ARG_TUN_SEARCH_MTU,0,5,2,A_CS1,A_ADM,A_DYI,A_CFA,A_ANY,0, 0, 0, 0,0, opt_tun_search,
+ ARG_VALUE_FORM, "specify MTU user in tunnel"}
,
{ODI,0,ARG_TUNS, 0,5,2,A_PS0,A_USR,A_DYN,A_ARG,A_ANY, 0, 0, 0, 0,0, opt_status,
0, "show announced gateways and tunnels"}
diff --git a/hna.h b/hna.h
index 9352bef..8ab4247 100644
--- a/hna.h
+++ b/hna.h
@@ -77,6 +77,7 @@
#define ARG_TUN_NET_LOCAL ARG_TUN_ADV
#define ARG_TUN_NET_BW "bandwidth"
+
#define ARG_TUN_SEARCH_NAME "tunOut"
#define ARG_TUN_SEARCH_NETWORK "network"
#define ARG_TUN_SEARCH_IP "address"
@@ -86,6 +87,8 @@
#define MAX_TUN_SEARCH_IPMETRIC INT32_MAX
#define ARG_TUN_SEARCH_HOSTNAME "gwName"
#define ARG_TUN_SEARCH_PKID "gwId"
+#define ARG_TUN_SEARCH_MTU "mtu"
+#define DEF_TUN_SEARCH_MTU 1460
struct net_key {
@@ -254,6 +257,7 @@ struct tun_search_node {
struct net_key network;
uint8_t networkMin;
uint32_t ipmetric;
+ uint32_t mtu;
GLOBAL_ID_T global_id;
struct net_key srcPrefix;
diff --git a/ip.c b/ip.c
index 96e4d90..0761c36 100644
--- a/ip.c
+++ b/ip.c
@@ -1369,6 +1369,25 @@ IDM_T iptunnel(IDM_T del, char *name, uint8_t proto, IPX_T *local, IPX_T *remote
return SUCCESS;
}
+IDM_T change_mtu(char *name, uint16_t mtu)
+{
+ struct ifreq req;
+
+ req.ifr_addr.sa_family = AF_INET;
+ strcpy(req.ifr_name, name);
+ if (ioctl(rt_sock, SIOCGIFMTU, (caddr_t)&req) < 0) {
+ dbgf_sys(DBGT_ERR, "Can't read '%s' device %s", name, strerror(errno));
+ return FAILURE;
+ }
+
+ req.ifr_mtu = mtu;
+ if (ioctl(rt_sock, SIOCSIFMTU, (caddr_t)&req) < 0) {
+ dbgf_sys(DBGT_ERR, "Can't set MTU from '%s' %s", name, strerror(errno));
+ return FAILURE;
+
+ }
+ return SUCCESS;
+}
STATIC_FUNC
diff --git a/ip.h b/ip.h
index bbc8a9e..bc709a8 100644
--- a/ip.h
+++ b/ip.h
@@ -509,6 +509,7 @@ uint32_t get_if_index(IFNAME_T *name);
IDM_T ipaddr(IDM_T del, uint32_t if_index, uint8_t family, IPX_T *ip, uint8_t prefixlen, IDM_T deprecated);
IDM_T iptunnel(IDM_T del, char *name, uint8_t proto, IPX_T *local, IPX_T *remote);
+IDM_T change_mtu(char *name, uint16_t mtu);
IDM_T ip(uint8_t family, uint8_t cmd, int8_t del, uint8_t quiet, const IPX_T *NET, uint8_t nmask,
int8_t table_macro, int8_t prio_macro, IFNAME_T *iifname, int oif_idx, IPX_T *via, IPX_T *src, uint32_t metric);
......@@ -606,6 +606,7 @@ qmp_configure_bmx6() {
uci set $conf.tun6Out="tunOut"
uci set $conf.tun6Out.tunOut="tun6Out"
uci set $conf.tun6Out.network="$(uci get qmp.tunnels.search_ipv6_tunnel)"
uci set $conf.tun6Out.mtu=1400
fi
......@@ -613,6 +614,7 @@ qmp_configure_bmx6() {
uci set $conf.tun4Out="tunOut"
uci set $conf.tun4Out.tunOut="tun4Out"
uci set $conf.tun4Out.network="$(uci get qmp.tunnels.search_ipv4_tunnel)"
uci set $conf.tun4Out.mtu=1400
elif qmp_uci_test qmp.tunnels.offer_ipv4_tunnel ; then
uci set $conf.tunInRemote="tunInRemote"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment