Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 404eb77e authored by Roopa Prabhu's avatar Roopa Prabhu Committed by David S. Miller
Browse files

ipv4: support sport, dport and ip_proto in RTM_GETROUTE



This is a followup to fib rules sport, dport and ipproto
match support. Only supports tcp, udp and icmp for ipproto.
Used by fib rule self tests.

Signed-off-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 273de02a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -664,4 +664,7 @@ extern int sysctl_icmp_msgs_burst;
int ip_misc_proc_init(void);
#endif

int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto,
				struct netlink_ext_ack *extack);

#endif	/* _IP_H */
+3 −0
Original line number Diff line number Diff line
@@ -327,6 +327,9 @@ enum rtattr_type_t {
	RTA_PAD,
	RTA_UID,
	RTA_TTL_PROPAGATE,
	RTA_IP_PROTO,
	RTA_SPORT,
	RTA_DPORT,
	__RTA_MAX
};

+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ obj-y := route.o inetpeer.o protocol.o \
	     udp_offload.o arp.o icmp.o devinet.o af_inet.o igmp.o \
	     fib_frontend.o fib_semantics.o fib_trie.o fib_notifier.o \
	     inet_fragment.o ping.o ip_tunnel_core.o gre_offload.o \
	     metrics.o
	     metrics.o netlink.o

obj-$(CONFIG_BPFILTER) += bpfilter/

+3 −0
Original line number Diff line number Diff line
@@ -649,6 +649,9 @@ const struct nla_policy rtm_ipv4_policy[RTA_MAX + 1] = {
	[RTA_ENCAP]		= { .type = NLA_NESTED },
	[RTA_UID]		= { .type = NLA_U32 },
	[RTA_MARK]		= { .type = NLA_U32 },
	[RTA_IP_PROTO]		= { .type = NLA_U8 },
	[RTA_SPORT]		= { .type = NLA_U16 },
	[RTA_DPORT]		= { .type = NLA_U16 },
};

static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,

net/ipv4/netlink.c

0 → 100644
+23 −0
Original line number Diff line number Diff line
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/types.h>
#include <net/net_namespace.h>
#include <net/netlink.h>
#include <net/ip.h>

int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto,
				struct netlink_ext_ack *extack)
{
	*ip_proto = nla_get_u8(attr);

	switch (*ip_proto) {
	case IPPROTO_TCP:
	case IPPROTO_UDP:
	case IPPROTO_ICMP:
		return 0;
	default:
		NL_SET_ERR_MSG(extack, "Unsupported ip proto");
		return -EOPNOTSUPP;
	}
}
EXPORT_SYMBOL_GPL(rtm_getroute_parse_ip_proto);
Loading