+static struct rtable *__find_route(const struct tnl_mutable_config *mutable,
+ u8 ipproto, u8 tos)
+{
+ /* Tunnel configuration keeps DSCP part of TOS bits, But Linux
+ * router expect RT_TOS bits only. */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
+ struct flowi fl = { .nl_u = { .ip4_u = {
+ .daddr = mutable->key.daddr,
+ .saddr = mutable->key.saddr,
+ .tos = RT_TOS(tos) } },
+ .proto = ipproto };
+ struct rtable *rt;
+
+ if (unlikely(ip_route_output_key(port_key_get_net(&mutable->key), &rt, &fl)))
+ return ERR_PTR(-EADDRNOTAVAIL);
+
+ return rt;
+#else
+ struct flowi4 fl = { .daddr = mutable->key.daddr,
+ .saddr = mutable->key.saddr,
+ .flowi4_tos = RT_TOS(tos),
+ .flowi4_proto = ipproto };
+
+ return ip_route_output_key(port_key_get_net(&mutable->key), &fl);
+#endif
+}
+