diff options
| -rw-r--r-- | include/net/ip.h | 2 | ||||
| -rw-r--r-- | net/ipv4/netlink.c | 17 | ||||
| -rw-r--r-- | net/ipv4/route.c | 2 | ||||
| -rw-r--r-- | net/ipv6/route.c | 3 |
4 files changed, 17 insertions, 7 deletions
diff --git a/include/net/ip.h b/include/net/ip.h index f0e8d064e249..be3cad9c2e4c 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
| @@ -718,7 +718,7 @@ extern int sysctl_icmp_msgs_burst; | |||
| 718 | int ip_misc_proc_init(void); | 718 | int ip_misc_proc_init(void); |
| 719 | #endif | 719 | #endif |
| 720 | 720 | ||
| 721 | int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, | 721 | int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, u8 family, |
| 722 | struct netlink_ext_ack *extack); | 722 | struct netlink_ext_ack *extack); |
| 723 | 723 | ||
| 724 | #endif /* _IP_H */ | 724 | #endif /* _IP_H */ |
diff --git a/net/ipv4/netlink.c b/net/ipv4/netlink.c index f86bb4f06609..d8e3a1fb8e82 100644 --- a/net/ipv4/netlink.c +++ b/net/ipv4/netlink.c | |||
| @@ -3,9 +3,10 @@ | |||
| 3 | #include <linux/types.h> | 3 | #include <linux/types.h> |
| 4 | #include <net/net_namespace.h> | 4 | #include <net/net_namespace.h> |
| 5 | #include <net/netlink.h> | 5 | #include <net/netlink.h> |
| 6 | #include <linux/in6.h> | ||
| 6 | #include <net/ip.h> | 7 | #include <net/ip.h> |
| 7 | 8 | ||
| 8 | int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, | 9 | int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, u8 family, |
| 9 | struct netlink_ext_ack *extack) | 10 | struct netlink_ext_ack *extack) |
| 10 | { | 11 | { |
| 11 | *ip_proto = nla_get_u8(attr); | 12 | *ip_proto = nla_get_u8(attr); |
| @@ -13,11 +14,19 @@ int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, | |||
| 13 | switch (*ip_proto) { | 14 | switch (*ip_proto) { |
| 14 | case IPPROTO_TCP: | 15 | case IPPROTO_TCP: |
| 15 | case IPPROTO_UDP: | 16 | case IPPROTO_UDP: |
| 17 | return 0; | ||
| 16 | case IPPROTO_ICMP: | 18 | case IPPROTO_ICMP: |
| 19 | if (family != AF_INET) | ||
| 20 | break; | ||
| 21 | return 0; | ||
| 22 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 23 | case IPPROTO_ICMPV6: | ||
| 24 | if (family != AF_INET6) | ||
| 25 | break; | ||
| 17 | return 0; | 26 | return 0; |
| 18 | default: | 27 | #endif |
| 19 | NL_SET_ERR_MSG(extack, "Unsupported ip proto"); | ||
| 20 | return -EOPNOTSUPP; | ||
| 21 | } | 28 | } |
| 29 | NL_SET_ERR_MSG(extack, "Unsupported ip proto"); | ||
| 30 | return -EOPNOTSUPP; | ||
| 22 | } | 31 | } |
| 23 | EXPORT_SYMBOL_GPL(rtm_getroute_parse_ip_proto); | 32 | EXPORT_SYMBOL_GPL(rtm_getroute_parse_ip_proto); |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 5163b64f8fb3..7bb9128c8363 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
| @@ -2803,7 +2803,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, | |||
| 2803 | 2803 | ||
| 2804 | if (tb[RTA_IP_PROTO]) { | 2804 | if (tb[RTA_IP_PROTO]) { |
| 2805 | err = rtm_getroute_parse_ip_proto(tb[RTA_IP_PROTO], | 2805 | err = rtm_getroute_parse_ip_proto(tb[RTA_IP_PROTO], |
| 2806 | &ip_proto, extack); | 2806 | &ip_proto, AF_INET, extack); |
| 2807 | if (err) | 2807 | if (err) |
| 2808 | return err; | 2808 | return err; |
| 2809 | } | 2809 | } |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index b7a620023a52..8dad1d690b78 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
| @@ -4893,7 +4893,8 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, | |||
| 4893 | 4893 | ||
| 4894 | if (tb[RTA_IP_PROTO]) { | 4894 | if (tb[RTA_IP_PROTO]) { |
| 4895 | err = rtm_getroute_parse_ip_proto(tb[RTA_IP_PROTO], | 4895 | err = rtm_getroute_parse_ip_proto(tb[RTA_IP_PROTO], |
| 4896 | &fl6.flowi6_proto, extack); | 4896 | &fl6.flowi6_proto, AF_INET6, |
| 4897 | extack); | ||
| 4897 | if (err) | 4898 | if (err) |
| 4898 | goto errout; | 4899 | goto errout; |
| 4899 | } | 4900 | } |
