From: Jiri Olsa <jolsa@redhat.com> Date: Tue, 12 Jan 2010 12:36:36 -0500 Subject: [net] iptables: fix routing of REJECT target packets Message-id: <1263299796-10546-1-git-send-email-jolsa@redhat.com> Patchwork-id: 22430 O-Subject: [PATCH RHEL5 BZ548079][REGRESSION] iptables: --reject-with tcp-reset doesn't work Bugzilla: 548079 RH-Acked-by: David S. Miller <davem@redhat.com> RH-Acked-by: Jiri Pirko <jpirko@redhat.com> RH-Acked-by: Neil Horman <nhorman@redhat.com> Bugzilla: 548079 https://bugzilla.redhat.com/show_bug.cgi?id=548079 Description: Signed-off-by: Jarod Wilson <jarod@redhat.com> diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c index 3b87f2f..20b76ea 100644 --- a/net/ipv4/netfilter/ipt_REJECT.c +++ b/net/ipv4/netfilter/ipt_REJECT.c @@ -47,16 +47,19 @@ static int ip_route_me_harder_compat(struct sk_buff *skb, unsigned addr_type) struct flowi fl = {}; struct dst_entry *odst; unsigned int hh_len; + unsigned int type; + type = inet_addr_type(iph->saddr); if (addr_type == RTN_UNSPEC) - addr_type = inet_addr_type(iph->saddr); + addr_type = type; /* some non-standard hacks like ipt_REJECT.c:send_reset() can cause * packets with foreign saddr to appear on the NF_INET_LOCAL_OUT hook. */ if (addr_type == RTN_LOCAL) { fl.nl_u.ip4_u.daddr = iph->daddr; - fl.nl_u.ip4_u.saddr = iph->saddr; + if (type == RTN_LOCAL) + fl.nl_u.ip4_u.saddr = iph->saddr; fl.nl_u.ip4_u.tos = RT_TOS(iph->tos); fl.oif = skb->sk ? skb->sk->sk_bound_dev_if : 0; #ifdef CONFIG_IP_ROUTE_FWMARK