diff --git a/ip/link_gre.c b/ip/link_gre.c index 6d71864c..010b4824 100644 --- a/ip/link_gre.c +++ b/ip/link_gre.c @@ -109,13 +109,8 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, if (!(n->nlmsg_flags & NLM_F_CREATE)) { const struct rtattr *rta; - if (rtnl_talk(&rth, &req.n, &answer) < 0) { -get_failed: - fprintf(stderr, - "Failed to get existing tunnel info.\n"); - free(answer); - return -1; - } + if (rtnl_talk(&rth, &req.n, &answer) < 0) + goto get_failed; len = answer->nlmsg_len; len -= NLMSG_LENGTH(sizeof(*ifi)); @@ -423,6 +418,11 @@ get_failed: addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport)); return 0; + +get_failed: + fprintf(stderr, "Failed to get existing tunnel info.\n"); + free(answer); + return -1; } static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) diff --git a/ip/link_gre6.c b/ip/link_gre6.c index 4d1c6574..fc3e35f7 100644 --- a/ip/link_gre6.c +++ b/ip/link_gre6.c @@ -111,13 +111,8 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, if (!(n->nlmsg_flags & NLM_F_CREATE)) { const struct rtattr *rta; - if (rtnl_talk(&rth, &req.n, &answer) < 0) { -get_failed: - fprintf(stderr, - "Failed to get existing tunnel info.\n"); - free(answer); - return -1; - } + if (rtnl_talk(&rth, &req.n, &answer) < 0) + goto get_failed; len = answer->nlmsg_len; len -= NLMSG_LENGTH(sizeof(*ifi)); @@ -441,6 +436,11 @@ get_failed: addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport)); return 0; + +get_failed: + fprintf(stderr, "Failed to get existing tunnel info.\n"); + free(answer); + return -1; } static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c index 3a30dca9..c2a05cee 100644 --- a/ip/link_ip6tnl.c +++ b/ip/link_ip6tnl.c @@ -97,13 +97,8 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv, if (!(n->nlmsg_flags & NLM_F_CREATE)) { const struct rtattr *rta; - if (rtnl_talk(&rth, &req.n, &answer) < 0) { -get_failed: - fprintf(stderr, - "Failed to get existing tunnel info.\n"); - free(answer); - return -1; - } + if (rtnl_talk(&rth, &req.n, &answer) < 0) + goto get_failed; len = answer->nlmsg_len; len -= NLMSG_LENGTH(sizeof(*ifi)); @@ -326,6 +321,11 @@ get_failed: addattr16(n, 1024, IFLA_IPTUN_ENCAP_DPORT, htons(encapdport)); return 0; + +get_failed: + fprintf(stderr, "Failed to get existing tunnel info.\n"); + free(answer); + return -1; } static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c index 879202f7..49c3ae26 100644 --- a/ip/link_iptnl.c +++ b/ip/link_iptnl.c @@ -101,13 +101,8 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv, if (!(n->nlmsg_flags & NLM_F_CREATE)) { const struct rtattr *rta; - if (rtnl_talk(&rth, &req.n, &answer) < 0) { -get_failed: - fprintf(stderr, - "Failed to get existing tunnel info.\n"); - free(answer); - return -1; - } + if (rtnl_talk(&rth, &req.n, &answer) < 0) + goto get_failed; len = answer->nlmsg_len; len -= NLMSG_LENGTH(sizeof(*ifi)); @@ -350,6 +345,11 @@ get_failed: } return 0; + +get_failed: + fprintf(stderr, "Failed to get existing tunnel info.\n"); + free(answer); + return -1; } static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) diff --git a/ip/link_vti.c b/ip/link_vti.c index 7a95dc02..2106a9d2 100644 --- a/ip/link_vti.c +++ b/ip/link_vti.c @@ -65,13 +65,8 @@ static int vti_parse_opt(struct link_util *lu, int argc, char **argv, if (!(n->nlmsg_flags & NLM_F_CREATE)) { const struct rtattr *rta; - if (rtnl_talk(&rth, &req.n, &answer) < 0) { -get_failed: - fprintf(stderr, - "Failed to get existing tunnel info.\n"); - free(answer); - return -1; - } + if (rtnl_talk(&rth, &req.n, &answer) < 0) + goto get_failed; len = answer->nlmsg_len; len -= NLMSG_LENGTH(sizeof(*ifi)); @@ -157,6 +152,11 @@ get_failed: addattr32(n, 1024, IFLA_VTI_LINK, link); return 0; + +get_failed: + fprintf(stderr, "Failed to get existing tunnel info.\n"); + free(answer); + return -1; } static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) diff --git a/ip/link_vti6.c b/ip/link_vti6.c index aaf701d3..7362f336 100644 --- a/ip/link_vti6.c +++ b/ip/link_vti6.c @@ -67,13 +67,8 @@ static int vti6_parse_opt(struct link_util *lu, int argc, char **argv, if (!(n->nlmsg_flags & NLM_F_CREATE)) { const struct rtattr *rta; - if (rtnl_talk(&rth, &req.n, &answer) < 0) { -get_failed: - fprintf(stderr, - "Failed to get existing tunnel info.\n"); - free(answer); - return -1; - } + if (rtnl_talk(&rth, &req.n, &answer) < 0) + goto get_failed; len = answer->nlmsg_len; len -= NLMSG_LENGTH(sizeof(*ifi)); @@ -159,6 +154,11 @@ get_failed: addattr32(n, 1024, IFLA_VTI_LINK, link); return 0; + +get_failed: + fprintf(stderr, "Failed to get existing tunnel info.\n"); + free(answer); + return -1; } static void vti6_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])