Commit f8f21471 authored by Scott Feldman's avatar Scott Feldman Committed by David S. Miller

switchdev: add netlink flags to IPv4 FIB add op

Pass in the netlink flags (NLM_F_*) into switchdev driver for IPv4 FIB add op
to allow driver to 1) optimize hardware updates, 2) handle ip route prepend
and append commands correctly.
Suggested-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Suggested-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: default avatarScott Feldman <sfeldma@gmail.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Acked-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bf0b2112
...@@ -4152,7 +4152,8 @@ static int rocker_port_switch_port_stp_update(struct net_device *dev, u8 state) ...@@ -4152,7 +4152,8 @@ static int rocker_port_switch_port_stp_update(struct net_device *dev, u8 state)
static int rocker_port_switch_fib_ipv4_add(struct net_device *dev, static int rocker_port_switch_fib_ipv4_add(struct net_device *dev,
__be32 dst, int dst_len, __be32 dst, int dst_len,
struct fib_info *fi, struct fib_info *fi,
u8 tos, u8 type, u32 tb_id) u8 tos, u8 type,
u32 nlflags, u32 tb_id)
{ {
struct rocker_port *rocker_port = netdev_priv(dev); struct rocker_port *rocker_port = netdev_priv(dev);
int flags = 0; int flags = 0;
......
...@@ -1035,7 +1035,7 @@ struct fib_info; ...@@ -1035,7 +1035,7 @@ struct fib_info;
* state change. * state change.
* int (*ndo_sw_parent_fib_ipv4_add)(struct net_device *dev, __be32 dst, * int (*ndo_sw_parent_fib_ipv4_add)(struct net_device *dev, __be32 dst,
* int dst_len, struct fib_info *fi, * int dst_len, struct fib_info *fi,
* u8 tos, u8 type, u32 tb_id); * u8 tos, u8 type, u32 nlflags, u32 tb_id);
* Called to add/modify IPv4 route to switch device. * Called to add/modify IPv4 route to switch device.
* int (*ndo_sw_parent_fib_ipv4_del)(struct net_device *dev, __be32 dst, * int (*ndo_sw_parent_fib_ipv4_del)(struct net_device *dev, __be32 dst,
* int dst_len, struct fib_info *fi, * int dst_len, struct fib_info *fi,
...@@ -1207,6 +1207,7 @@ struct net_device_ops { ...@@ -1207,6 +1207,7 @@ struct net_device_ops {
int dst_len, int dst_len,
struct fib_info *fi, struct fib_info *fi,
u8 tos, u8 type, u8 tos, u8 type,
u32 nlflags,
u32 tb_id); u32 tb_id);
int (*ndo_switch_fib_ipv4_del)(struct net_device *dev, int (*ndo_switch_fib_ipv4_del)(struct net_device *dev,
__be32 dst, __be32 dst,
......
/* /*
* include/net/switchdev.h - Switch device API * include/net/switchdev.h - Switch device API
* Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us> * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
* Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -52,7 +53,7 @@ int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev, ...@@ -52,7 +53,7 @@ int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev, int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
struct nlmsghdr *nlh, u16 flags); struct nlmsghdr *nlh, u16 flags);
int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
u8 tos, u8 type, u32 tb_id); u8 tos, u8 type, u32 nlflags, u32 tb_id);
int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
u8 tos, u8 type, u32 tb_id); u8 tos, u8 type, u32 tb_id);
void netdev_switch_fib_ipv4_abort(struct fib_info *fi); void netdev_switch_fib_ipv4_abort(struct fib_info *fi);
...@@ -117,7 +118,8 @@ static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device * ...@@ -117,7 +118,8 @@ static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *
static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len,
struct fib_info *fi, struct fib_info *fi,
u8 tos, u8 type, u32 tb_id) u8 tos, u8 type,
u32 nlflags, u32 tb_id)
{ {
return 0; return 0;
} }
......
...@@ -1155,6 +1155,7 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) ...@@ -1155,6 +1155,7 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
err = netdev_switch_fib_ipv4_add(key, plen, fi, err = netdev_switch_fib_ipv4_add(key, plen, fi,
new_fa->fa_tos, new_fa->fa_tos,
cfg->fc_type, cfg->fc_type,
cfg->fc_nlflags,
tb->tb_id); tb->tb_id);
if (err) { if (err) {
netdev_switch_fib_ipv4_abort(fi); netdev_switch_fib_ipv4_abort(fi);
...@@ -1201,7 +1202,9 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) ...@@ -1201,7 +1202,9 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
/* (Optionally) offload fib entry to switch hardware. */ /* (Optionally) offload fib entry to switch hardware. */
err = netdev_switch_fib_ipv4_add(key, plen, fi, tos, err = netdev_switch_fib_ipv4_add(key, plen, fi, tos,
cfg->fc_type, tb->tb_id); cfg->fc_type,
cfg->fc_nlflags,
tb->tb_id);
if (err) { if (err) {
netdev_switch_fib_ipv4_abort(fi); netdev_switch_fib_ipv4_abort(fi);
goto out_free_new_fa; goto out_free_new_fa;
......
/* /*
* net/switchdev/switchdev.c - Switch device API * net/switchdev/switchdev.c - Switch device API
* Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us> * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
* Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -294,12 +295,13 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi) ...@@ -294,12 +295,13 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi)
* @fi: route FIB info structure * @fi: route FIB info structure
* @tos: route TOS * @tos: route TOS
* @type: route type * @type: route type
* @nlflags: netlink flags passed in (NLM_F_*)
* @tb_id: route table ID * @tb_id: route table ID
* *
* Add IPv4 route entry to switch device. * Add IPv4 route entry to switch device.
*/ */
int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
u8 tos, u8 type, u32 tb_id) u8 tos, u8 type, u32 nlflags, u32 tb_id)
{ {
struct net_device *dev; struct net_device *dev;
const struct net_device_ops *ops; const struct net_device_ops *ops;
...@@ -324,7 +326,8 @@ int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, ...@@ -324,7 +326,8 @@ int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
if (ops->ndo_switch_fib_ipv4_add) { if (ops->ndo_switch_fib_ipv4_add) {
err = ops->ndo_switch_fib_ipv4_add(dev, htonl(dst), dst_len, err = ops->ndo_switch_fib_ipv4_add(dev, htonl(dst), dst_len,
fi, tos, type, tb_id); fi, tos, type, nlflags,
tb_id);
if (!err) if (!err)
fi->fib_flags |= RTNH_F_EXTERNAL; fi->fib_flags |= RTNH_F_EXTERNAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment