As a historical note, this code goes all the way back to Rusty in
2.3.14, where it looked like this:
#ifdef CONFIG_NETFILTER
/* To preserve the cute illusion that a locally-generated packet can
be mangled before routing, we actually reroute if a hook altered
the packet. -RR */
static int route_me_harder(struct sk_buff *skb)
{
struct iphdr *iph = skb->nh.iph;
struct rtable *rt;
if (ip_route_output(&rt, iph->daddr, iph->saddr,
RT_TOS(iph->tos) | RTO_CONN,
skb->sk ? skb->sk->bound_dev_if : 0)) {
printk("route_me_harder: No more route.\n");
return -EINVAL;
}
/* Drop old route. */
dst_release(skb->dst);
skb->dst = &rt->u.dst;
return 0;
}
#endif
And until now, it was never updated to take the separate sock *sk parameter.