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: Jamal Hadi Salim <[email protected]>
Suggested-by: Roopa Prabhu <[email protected]>
Signed-off-by: Scott Feldman <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Acked-by: Roopa Prabhu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 9095545..fcfa982 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1155,6 +1155,7 @@
 			err = netdev_switch_fib_ipv4_add(key, plen, fi,
 							 new_fa->fa_tos,
 							 cfg->fc_type,
+							 cfg->fc_nlflags,
 							 tb->tb_id);
 			if (err) {
 				netdev_switch_fib_ipv4_abort(fi);
@@ -1201,7 +1202,9 @@
 
 	/* (Optionally) offload fib entry to switch hardware. */
 	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) {
 		netdev_switch_fib_ipv4_abort(fi);
 		goto out_free_new_fa;
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index aba6aa2..8cf42a6 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -1,6 +1,7 @@
 /*
  * net/switchdev/switchdev.c - Switch device API
  * Copyright (c) 2014 Jiri Pirko <[email protected]>
+ * Copyright (c) 2014-2015 Scott Feldman <[email protected]>
  *
  * 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
@@ -294,12 +295,13 @@
  *	@fi: route FIB info structure
  *	@tos: route TOS
  *	@type: route type
+ *	@nlflags: netlink flags passed in (NLM_F_*)
  *	@tb_id: route table ID
  *
  *	Add IPv4 route entry to switch device.
  */
 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;
 	const struct net_device_ops *ops;
@@ -324,7 +326,8 @@
 
 	if (ops->ndo_switch_fib_ipv4_add) {
 		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)
 			fi->fib_flags |= RTNH_F_EXTERNAL;
 	}