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

Commit ee6b9673 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

[IPV4]: Add 'rtable' field in struct sk_buff to alias 'dst' and avoid casts



(Anonymous) unions can help us to avoid ugly casts.

A common cast it the (struct rtable *)skb->dst one.

Defining an union like  :
union {
     struct dst_entry *dst;
     struct rtable *rtable;
};
permits to use skb->rtable in place.

Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a05c44f6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -256,7 +256,10 @@ struct sk_buff {
	ktime_t			tstamp;
	struct net_device	*dev;

	union {
		struct  dst_entry	*dst;
		struct  rtable		*rtable;
	};
	struct	sec_path	*sp;

	/*
+1 −1
Original line number Diff line number Diff line
@@ -195,7 +195,7 @@ static inline int inet_sk_ehashfn(const struct sock *sk)

static inline int inet_iif(const struct sk_buff *skb)
{
	return ((struct rtable *)skb->dst)->rt_iif;
	return skb->rtable->rt_iif;
}

#endif	/* _INET_SOCK_H */
+7 −7
Original line number Diff line number Diff line
@@ -223,8 +223,8 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)
	}
	nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;

	skb->dst = (struct dst_entry *)&__fake_rtable;
	dst_hold(skb->dst);
	skb->rtable = &__fake_rtable;
	dst_hold(&__fake_rtable.u.dst);

	skb->dev = nf_bridge->physindev;
	nf_bridge_push_encap_header(skb);
@@ -388,8 +388,8 @@ bridged_dnat:
			skb->pkt_type = PACKET_HOST;
		}
	} else {
		skb->dst = (struct dst_entry *)&__fake_rtable;
		dst_hold(skb->dst);
		skb->rtable = &__fake_rtable;
		dst_hold(&__fake_rtable.u.dst);
	}

	skb->dev = nf_bridge->physindev;
@@ -608,9 +608,9 @@ static unsigned int br_nf_local_in(unsigned int hook, struct sk_buff *skb,
				   const struct net_device *out,
				   int (*okfn)(struct sk_buff *))
{
	if (skb->dst == (struct dst_entry *)&__fake_rtable) {
		dst_release(skb->dst);
		skb->dst = NULL;
	if (skb->rtable == &__fake_rtable) {
		dst_release(&__fake_rtable.u.dst);
		skb->rtable = NULL;
	}

	return NF_ACCEPT;
+3 −4
Original line number Diff line number Diff line
@@ -450,7 +450,7 @@ static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
					   struct sk_buff *skb)
{
	struct rtable *rt;
	struct flowi fl = { .oif = ((struct rtable *)skb->dst)->rt_iif,
	struct flowi fl = { .oif = skb->rtable->rt_iif,
			    .nl_u = { .ip4_u =
				      { .daddr = ip_hdr(skb)->saddr,
					.saddr = ip_hdr(skb)->daddr,
@@ -511,7 +511,7 @@ static void dccp_v4_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
	if (dccp_hdr(rxskb)->dccph_type == DCCP_PKT_RESET)
		return;

	if (((struct rtable *)rxskb->dst)->rt_type != RTN_LOCAL)
	if (rxskb->rtable->rt_type != RTN_LOCAL)
		return;

	dst = dccp_v4_route_skb(dccp_v4_ctl_socket->sk, rxskb);
@@ -563,8 +563,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
	struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);

	/* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
	if (((struct rtable *)skb->dst)->rt_flags &
	    (RTCF_BROADCAST | RTCF_MULTICAST))
	if (skb->rtable->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
		return 0;	/* discard, don't send a reset here */

	if (dccp_bad_service_code(sk, service)) {
+2 −2
Original line number Diff line number Diff line
@@ -475,7 +475,7 @@ int arp_find(unsigned char *haddr, struct sk_buff *skb)
		return 1;
	}

	paddr = ((struct rtable*)skb->dst)->rt_gateway;
	paddr = skb->rtable->rt_gateway;

	if (arp_set_predefined(inet_addr_type(&init_net, paddr), haddr, paddr, dev))
		return 0;
@@ -814,7 +814,7 @@ static int arp_process(struct sk_buff *skb)
	if (arp->ar_op == htons(ARPOP_REQUEST) &&
	    ip_route_input(skb, tip, sip, 0, dev) == 0) {

		rt = (struct rtable*)skb->dst;
		rt = skb->rtable;
		addr_type = rt->rt_type;

		if (addr_type == RTN_LOCAL) {
Loading