ipv4: Reject routes specifying ECN bits in rtm_tos
Use the new dscp_t type to replace the fc_tos field of fib_config, to ensure IPv4 routes aren't influenced by ECN bits when configured with non-zero rtm_tos. Before this patch, IPv4 routes specifying an rtm_tos with some of the ECN bits set were accepted. However they wouldn't work (never match) as IPv4 normally clears the ECN bits with IPTOS_RT_MASK before doing a FIB lookup (although a few buggy code paths don't). After this patch, IPv4 routes specifying an rtm_tos with any ECN bit set is rejected. Note: IPv6 routes ignore rtm_tos altogether, any rtm_tos is accepted, but treated as if it were 0. Signed-off-by: Guillaume Nault <gnault@redhat.com> Acked-by: David Ahern <dsahern@kernel.org> Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
563f8e97e0
commit
f55fbb6afb
@@ -32,6 +32,7 @@
|
||||
#include <linux/list.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <net/inet_dscp.h>
|
||||
#include <net/ip.h>
|
||||
#include <net/protocol.h>
|
||||
#include <net/route.h>
|
||||
@@ -735,8 +736,16 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
|
||||
memset(cfg, 0, sizeof(*cfg));
|
||||
|
||||
rtm = nlmsg_data(nlh);
|
||||
|
||||
if (!inet_validate_dscp(rtm->rtm_tos)) {
|
||||
NL_SET_ERR_MSG(extack,
|
||||
"Invalid dsfield (tos): ECN bits must be 0");
|
||||
err = -EINVAL;
|
||||
goto errout;
|
||||
}
|
||||
cfg->fc_dscp = inet_dsfield_to_dscp(rtm->rtm_tos);
|
||||
|
||||
cfg->fc_dst_len = rtm->rtm_dst_len;
|
||||
cfg->fc_tos = rtm->rtm_tos;
|
||||
cfg->fc_table = rtm->rtm_table;
|
||||
cfg->fc_protocol = rtm->rtm_protocol;
|
||||
cfg->fc_scope = rtm->rtm_scope;
|
||||
|
Reference in New Issue
Block a user