1 // SPDX-License-Identifier: GPL-2.0-only << 2 #include <linux/netlink.h> 1 #include <linux/netlink.h> 3 #include <linux/rtnetlink.h> 2 #include <linux/rtnetlink.h> 4 #include <linux/types.h> 3 #include <linux/types.h> 5 #include <net/net_namespace.h> 4 #include <net/net_namespace.h> 6 #include <net/netlink.h> 5 #include <net/netlink.h> 7 #include <linux/in6.h> 6 #include <linux/in6.h> 8 #include <net/ip.h> 7 #include <net/ip.h> 9 8 10 int rtm_getroute_parse_ip_proto(struct nlattr 9 int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, u8 family, 11 struct netlink 10 struct netlink_ext_ack *extack) 12 { 11 { 13 *ip_proto = nla_get_u8(attr); 12 *ip_proto = nla_get_u8(attr); 14 13 15 switch (*ip_proto) { 14 switch (*ip_proto) { 16 case IPPROTO_TCP: 15 case IPPROTO_TCP: 17 case IPPROTO_UDP: 16 case IPPROTO_UDP: 18 return 0; 17 return 0; 19 case IPPROTO_ICMP: 18 case IPPROTO_ICMP: 20 if (family != AF_INET) 19 if (family != AF_INET) 21 break; 20 break; 22 return 0; 21 return 0; 23 #if IS_ENABLED(CONFIG_IPV6) 22 #if IS_ENABLED(CONFIG_IPV6) 24 case IPPROTO_ICMPV6: 23 case IPPROTO_ICMPV6: 25 if (family != AF_INET6) 24 if (family != AF_INET6) 26 break; 25 break; 27 return 0; 26 return 0; 28 #endif 27 #endif 29 } 28 } 30 NL_SET_ERR_MSG(extack, "Unsupported ip 29 NL_SET_ERR_MSG(extack, "Unsupported ip proto"); 31 return -EOPNOTSUPP; 30 return -EOPNOTSUPP; 32 } 31 } 33 EXPORT_SYMBOL_GPL(rtm_getroute_parse_ip_proto) 32 EXPORT_SYMBOL_GPL(rtm_getroute_parse_ip_proto); 34 33
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.