summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/route/link/can.c14
-rw-r--r--lib/route/link/ip6tnl.c14
-rw-r--r--lib/route/link/ipgre.c14
-rw-r--r--lib/route/link/ipip.c14
-rw-r--r--lib/route/link/ipvti.c14
-rw-r--r--lib/route/link/macvlan.c10
-rw-r--r--lib/route/link/sit.c14
-rw-r--r--lib/route/link/vlan.c12
-rw-r--r--lib/route/link/vxlan.c10
9 files changed, 77 insertions, 39 deletions
diff --git a/lib/route/link/can.c b/lib/route/link/can.c
index 489119d..4ce554b 100644
--- a/lib/route/link/can.c
+++ b/lib/route/link/can.c
@@ -73,11 +73,15 @@ static int can_alloc(struct rtnl_link *link)
{
struct can_info *ci;
- ci = calloc(1, sizeof(*ci));
- if (!ci)
- return -NLE_NOMEM;
-
- link->l_info = ci;
+ if (link->l_info)
+ memset(link->l_info, 0, sizeof(*ci));
+ else {
+ ci = calloc(1, sizeof(*ci));
+ if (!ci)
+ return -NLE_NOMEM;
+
+ link->l_info = ci;
+ }
return 0;
}
diff --git a/lib/route/link/ip6tnl.c b/lib/route/link/ip6tnl.c
index 26f3507..378b8a3 100644
--- a/lib/route/link/ip6tnl.c
+++ b/lib/route/link/ip6tnl.c
@@ -73,11 +73,15 @@ static int ip6_tnl_alloc(struct rtnl_link *link)
{
struct ip6_tnl_info *ip6_tnl;
- ip6_tnl = calloc(1, sizeof(*ip6_tnl));
- if (!ip6_tnl)
- return -NLE_NOMEM;
-
- link->l_info = ip6_tnl;
+ if (link->l_info)
+ memset(link->l_info, 0, sizeof(*ip6_tnl));
+ else {
+ ip6_tnl = calloc(1, sizeof(*ip6_tnl));
+ if (!ip6_tnl)
+ return -NLE_NOMEM;
+
+ link->l_info = ip6_tnl;
+ }
return 0;
}
diff --git a/lib/route/link/ipgre.c b/lib/route/link/ipgre.c
index 3927ab4..2ff03fc 100644
--- a/lib/route/link/ipgre.c
+++ b/lib/route/link/ipgre.c
@@ -75,11 +75,15 @@ static int ipgre_alloc(struct rtnl_link *link)
{
struct ipgre_info *ipgre;
- ipgre = calloc(1, sizeof(*ipgre));
- if (!ipgre)
- return -NLE_NOMEM;
-
- link->l_info = ipgre;
+ if (link->l_info)
+ memset(link->l_info, 0, sizeof(*ipgre));
+ else {
+ ipgre = calloc(1, sizeof(*ipgre));
+ if (!ipgre)
+ return -NLE_NOMEM;
+
+ link->l_info = ipgre;
+ }
return 0;
}
diff --git a/lib/route/link/ipip.c b/lib/route/link/ipip.c
index ecf86ad..38f8fef 100644
--- a/lib/route/link/ipip.c
+++ b/lib/route/link/ipip.c
@@ -62,11 +62,15 @@ static int ipip_alloc(struct rtnl_link *link)
{
struct ipip_info *ipip;
- ipip = calloc(1, sizeof(*ipip));
- if (!ipip)
- return -NLE_NOMEM;
-
- link->l_info = ipip;
+ if (link->l_info)
+ memset(link->l_info, 0, sizeof(*ipip));
+ else {
+ ipip = calloc(1, sizeof(*ipip));
+ if (!ipip)
+ return -NLE_NOMEM;
+
+ link->l_info = ipip;
+ }
return 0;
}
diff --git a/lib/route/link/ipvti.c b/lib/route/link/ipvti.c
index 71f61c3..b94c573 100644
--- a/lib/route/link/ipvti.c
+++ b/lib/route/link/ipvti.c
@@ -59,11 +59,15 @@ static int ipvti_alloc(struct rtnl_link *link)
{
struct ipvti_info *ipvti;
- ipvti = calloc(1, sizeof(*ipvti));
- if (!ipvti)
- return -NLE_NOMEM;
-
- link->l_info = ipvti;
+ if (link->l_info)
+ memset(link->l_info, 0, sizeof(*ipvti));
+ else {
+ ipvti = calloc(1, sizeof(*ipvti));
+ if (!ipvti)
+ return -NLE_NOMEM;
+
+ link->l_info = ipvti;
+ }
return 0;
}
diff --git a/lib/route/link/macvlan.c b/lib/route/link/macvlan.c
index c3eeb3f..b8380aa 100644
--- a/lib/route/link/macvlan.c
+++ b/lib/route/link/macvlan.c
@@ -55,10 +55,14 @@ static int macvlan_alloc(struct rtnl_link *link)
{
struct macvlan_info *mvi;
- if ((mvi = calloc(1, sizeof(*mvi))) == NULL)
- return -NLE_NOMEM;
+ if (link->l_info)
+ memset(link->l_info, 0, sizeof(*mvi));
+ else {
+ if ((mvi = calloc(1, sizeof(*mvi))) == NULL)
+ return -NLE_NOMEM;
- link->l_info = mvi;
+ link->l_info = mvi;
+ }
return 0;
}
diff --git a/lib/route/link/sit.c b/lib/route/link/sit.c
index 0fc1ecd..788bbb8 100644
--- a/lib/route/link/sit.c
+++ b/lib/route/link/sit.c
@@ -69,11 +69,15 @@ static int sit_alloc(struct rtnl_link *link)
{
struct sit_info *sit;
- sit = calloc(1, sizeof(*sit));
- if (!sit)
- return -NLE_NOMEM;
-
- link->l_info = sit;
+ if (link->l_info)
+ memset(link->l_info, 0, sizeof(*sit));
+ else {
+ sit = calloc(1, sizeof(*sit));
+ if (!sit)
+ return -NLE_NOMEM;
+
+ link->l_info = sit;
+ }
return 0;
}
diff --git a/lib/route/link/vlan.c b/lib/route/link/vlan.c
index f977bc4..9dc0d42 100644
--- a/lib/route/link/vlan.c
+++ b/lib/route/link/vlan.c
@@ -67,10 +67,16 @@ static int vlan_alloc(struct rtnl_link *link)
{
struct vlan_info *vi;
- if ((vi = calloc(1, sizeof(*vi))) == NULL)
- return -NLE_NOMEM;
+ if (link->l_info) {
+ vi = link->l_info;
+ free(vi->vi_egress_qos);
+ memset(link->l_info, 0, sizeof(*vi));
+ } else {
+ if ((vi = calloc(1, sizeof(*vi))) == NULL)
+ return -NLE_NOMEM;
- link->l_info = vi;
+ link->l_info = vi;
+ }
return 0;
}
diff --git a/lib/route/link/vxlan.c b/lib/route/link/vxlan.c
index f3e3538..8a9c6e0 100644
--- a/lib/route/link/vxlan.c
+++ b/lib/route/link/vxlan.c
@@ -91,10 +91,14 @@ static int vxlan_alloc(struct rtnl_link *link)
{
struct vxlan_info *vxi;
- if ((vxi = calloc(1, sizeof(*vxi))) == NULL)
- return -NLE_NOMEM;
+ if (link->l_info)
+ memset(link->l_info, 0, sizeof(*vxi));
+ else {
+ if ((vxi = calloc(1, sizeof(*vxi))) == NULL)
+ return -NLE_NOMEM;
- link->l_info = vxi;
+ link->l_info = vxi;
+ }
return 0;
}