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

Commit c7537967 authored by David S. Miller's avatar David S. Miller
Browse files

ipv4: Make rt->fl.iif tests lest obscure.



When we test rt->fl.iif against zero, we're seeing if it's
an output or an input route.

Make that explicit with some helper functions.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ed1deb70
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -80,6 +80,16 @@ struct dn_route {
	unsigned rt_type;
};

static inline bool dn_is_input_route(struct dn_route *rt)
{
	return rt->fl.iif != 0;
}

static inline bool dn_is_output_route(struct dn_route *rt)
{
	return rt->fl.iif == 0;
}

extern void dn_route_init(void);
extern void dn_route_cleanup(void);

+10 −0
Original line number Diff line number Diff line
@@ -71,6 +71,16 @@ struct rtable {
	struct inet_peer	*peer; /* long-living peer info */
};

static inline bool rt_is_input_route(struct rtable *rt)
{
	return rt->fl.iif != 0;
}

static inline bool rt_is_output_route(struct rtable *rt)
{
	return rt->fl.iif == 0;
}

struct ip_rt_acct {
	__u32 	o_bytes;
	__u32 	o_packets;
+2 −2
Original line number Diff line number Diff line
@@ -1181,7 +1181,7 @@ static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *fl
			if ((flp->fld_dst == rt->fl.fld_dst) &&
			    (flp->fld_src == rt->fl.fld_src) &&
			    (flp->mark == rt->fl.mark) &&
			    (rt->fl.iif == 0) &&
			    dn_is_output_route(rt) &&
			    (rt->fl.oif == flp->oif)) {
				dst_use(&rt->dst, jiffies);
				rcu_read_unlock_bh();
@@ -1512,7 +1512,7 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
	if (rtnl_put_cacheinfo(skb, &rt->dst, 0, 0, 0, expires,
			       rt->dst.error) < 0)
		goto rtattr_failure;
	if (rt->fl.iif)
	if (dn_is_input_route(rt))
		RTA_PUT(skb, RTA_IIF, sizeof(int), &rt->fl.iif);

	nlh->nlmsg_len = skb_tail_pointer(skb) - b;
+2 −2
Original line number Diff line number Diff line
@@ -506,7 +506,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
		struct net_device *dev = NULL;

		rcu_read_lock();
		if (rt->fl.iif &&
		if (rt_is_input_route(rt) &&
		    net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr)
			dev = dev_get_by_index_rcu(net, rt->fl.iif);

+1 −1
Original line number Diff line number Diff line
@@ -961,7 +961,7 @@ int igmp_rcv(struct sk_buff *skb)
	case IGMP_HOST_MEMBERSHIP_REPORT:
	case IGMPV2_HOST_MEMBERSHIP_REPORT:
		/* Is it our report looped back? */
		if (skb_rtable(skb)->fl.iif == 0)
		if (rt_is_output_route(skb_rtable(skb)))
			break;
		/* don't rely on MC router hearing unicast reports */
		if (skb->pkt_type == PACKET_MULTICAST ||
Loading