vrf.c (d66f6c0a8f3c0bcc4ee7a9b1da4b0ebe7ee555a3) vrf.c (8a966fc016b67d2a8ab4a83d22ded8cde032a0eb)
1/*
2 * vrf.c: device driver to encapsulate a VRF space
3 *
4 * Copyright (c) 2015 Cumulus Networks. All rights reserved.
5 * Copyright (c) 2015 Shrijeet Mukherjee <shm@cumulusnetworks.com>
6 * Copyright (c) 2015 David Ahern <dsa@cumulusnetworks.com>
7 *
8 * Based on dummy, team and ipvlan drivers

--- 1070 unchanged lines hidden (view full) ---

1079 flags |= RT6_LOOKUP_F_HAS_SADDR;
1080
1081 rt = vrf_ip6_route_lookup(net, dev, fl6, fl6->flowi6_oif, flags);
1082 if (rt)
1083 dst = &rt->dst;
1084
1085 return dst;
1086}
1/*
2 * vrf.c: device driver to encapsulate a VRF space
3 *
4 * Copyright (c) 2015 Cumulus Networks. All rights reserved.
5 * Copyright (c) 2015 Shrijeet Mukherjee <shm@cumulusnetworks.com>
6 * Copyright (c) 2015 David Ahern <dsa@cumulusnetworks.com>
7 *
8 * Based on dummy, team and ipvlan drivers

--- 1070 unchanged lines hidden (view full) ---

1079 flags |= RT6_LOOKUP_F_HAS_SADDR;
1080
1081 rt = vrf_ip6_route_lookup(net, dev, fl6, fl6->flowi6_oif, flags);
1082 if (rt)
1083 dst = &rt->dst;
1084
1085 return dst;
1086}
1087
1088/* called under rcu_read_lock */
1089static int vrf_get_saddr6(struct net_device *dev, const struct sock *sk,
1090 struct flowi6 *fl6)
1091{
1092 struct net *net = dev_net(dev);
1093 struct dst_entry *dst;
1094 struct rt6_info *rt;
1095 int err;
1096
1097 if (rt6_need_strict(&fl6->daddr)) {
1098 rt = vrf_ip6_route_lookup(net, dev, fl6, fl6->flowi6_oif,
1099 RT6_LOOKUP_F_IFACE);
1100 if (unlikely(!rt))
1101 return 0;
1102
1103 dst = &rt->dst;
1104 } else {
1105 __u8 flags = fl6->flowi6_flags;
1106
1107 fl6->flowi6_flags |= FLOWI_FLAG_L3MDEV_SRC;
1108 fl6->flowi6_flags |= FLOWI_FLAG_SKIP_NH_OIF;
1109
1110 dst = ip6_route_output(net, sk, fl6);
1111 rt = (struct rt6_info *)dst;
1112
1113 fl6->flowi6_flags = flags;
1114 }
1115
1116 err = dst->error;
1117 if (!err) {
1118 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
1119 sk ? inet6_sk(sk)->srcprefs : 0,
1120 &fl6->saddr);
1121 }
1122
1123 dst_release(dst);
1124
1125 return err;
1126}
1127#endif
1128
1129static const struct l3mdev_ops vrf_l3mdev_ops = {
1130 .l3mdev_fib_table = vrf_fib_table,
1131 .l3mdev_get_rtable = vrf_get_rtable,
1132 .l3mdev_l3_rcv = vrf_l3_rcv,
1133 .l3mdev_l3_out = vrf_l3_out,
1134#if IS_ENABLED(CONFIG_IPV6)
1135 .l3mdev_link_scope_lookup = vrf_link_scope_lookup,
1087#endif
1088
1089static const struct l3mdev_ops vrf_l3mdev_ops = {
1090 .l3mdev_fib_table = vrf_fib_table,
1091 .l3mdev_get_rtable = vrf_get_rtable,
1092 .l3mdev_l3_rcv = vrf_l3_rcv,
1093 .l3mdev_l3_out = vrf_l3_out,
1094#if IS_ENABLED(CONFIG_IPV6)
1095 .l3mdev_link_scope_lookup = vrf_link_scope_lookup,
1136 .l3mdev_get_saddr6 = vrf_get_saddr6,
1137#endif
1138};
1139
1140static void vrf_get_drvinfo(struct net_device *dev,
1141 struct ethtool_drvinfo *info)
1142{
1143 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
1144 strlcpy(info->version, DRV_VERSION, sizeof(info->version));

--- 273 unchanged lines hidden ---
1096#endif
1097};
1098
1099static void vrf_get_drvinfo(struct net_device *dev,
1100 struct ethtool_drvinfo *info)
1101{
1102 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
1103 strlcpy(info->version, DRV_VERSION, sizeof(info->version));

--- 273 unchanged lines hidden ---