Project

General

Profile

Bug #1952 » 0002-link-gtp-add-support-for-local-listener-address.patch

pablo, 10/27/2023 02:34 PM

View differences:

include/uapi/linux/if_link.h
905 905
	IFLA_GTP_ROLE,
906 906
	IFLA_GTP_CREATE_SOCKETS,
907 907
	IFLA_GTP_RESTART_COUNT,
908
	IFLA_GTP_LOCAL,
909
	IFLA_GTP_LOCAL6,
908 910
	__IFLA_GTP_MAX,
909 911
};
910 912
#define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1)
ip/iplink_gtp.c
34 34
static int gtp_parse_opt(struct link_util *lu, int argc, char **argv,
35 35
			 struct nlmsghdr *n)
36 36
{
37
	inet_prefix saddr;
37 38
	__u32 attrs = 0;
38 39

  
40
	saddr.family = AF_UNSPEC;
41
	inet_prefix_reset(&saddr);
42

  
39 43
	/* When creating GTP device through ip link,
40 44
	 * this flag has to be set.
41 45
	 */
......
71 75
			if (get_u8(&restart_count, *argv, 10))
72 76
				invarg("invalid restart_count", *argv);
73 77
			addattr8(n, 1024, IFLA_GTP_RESTART_COUNT, restart_count);
78
		} else if (!strcmp(*argv, "local")) {
79
			NEXT_ARG();
80
			check_duparg(&attrs, IFLA_GTP_LOCAL, "local", *argv);
81
			get_addr(&saddr, *argv, saddr.family);
82
			if (!is_addrtype_inet_not_multi(&saddr))
83
				invarg("invalid local address", *argv);
74 84
		} else if (!strcmp(*argv, "help")) {
75 85
			print_explain(stderr);
76 86
			return -1;
......
86 96
	if (!GTP_ATTRSET(attrs, IFLA_GTP_PDP_HASHSIZE))
87 97
		addattr32(n, 1024, IFLA_GTP_PDP_HASHSIZE, 1024);
88 98

  
99
	if (is_addrtype_inet(&saddr)) {
100
		int type;
101

  
102
		switch (saddr.family) {
103
		case AF_INET:
104
			type = IFLA_GTP_LOCAL;
105
			break;
106
		case AF_INET6:
107
			type = IFLA_GTP_LOCAL6;
108
			break;
109
		default:
110
			fprintf(stderr, "gtp: unsupported family\n");
111
			return -1;
112
		}
113
		addattr_l(n, 1024, type, saddr.data, saddr.bytelen);
114
	}
115

  
89 116
	return 0;
90 117
}
91 118

  
man/man8/ip-link.8.in
2025 2025
.I GTP
2026 2026
the following additional arguments are supported:
2027 2027

  
2028
.BI "ip link add " DEVICE " type gtp role " ROLE " hsize " HSIZE
2028
.BI "ip link add " DEVICE " type gtp role " ROLE " local  "{ "IPADDR " | "any " } " hsize " HSIZE
2029 2029

  
2030 2030
.in +8
2031 2031
.sp
2032 2032
.BI role " ROLE "
2033 2033
- specifies the role of the GTP device, either sgsn or ggsn
2034 2034

  
2035
.sp
2036
.BI local "{ "IPADDR " | "any " } "
2037
- specifies UDP socket listener IP address
2038

  
2035 2039
.sp
2036 2040
.BI hsize " HSIZE "
2037 2041
- specifies size of the hashtable which stores PDP contexts
(4-4/31)
Add picture from clipboard (Maximum size: 48.8 MB)