Merge branch 'lsk-v4.4-eas-v5.2' of git://git.linaro.org/arm/eas/kernel.git
[firefly-linux-kernel-4.4.55.git] / include / net / fib_rules.h
index 4ac12e14c6d98b36c2ecdde79de1f0051ab2fe22..55b5419cb6a7909ed0723b09c6608b30d7a33843 100644 (file)
 
 struct fib_rule {
        struct list_head        list;
-       atomic_t                refcnt;
        int                     iifindex;
        int                     oifindex;
        u32                     mark;
        u32                     mark_mask;
-       u32                     pref;
        u32                     flags;
        u32                     table;
        u8                      action;
+       /* 3 bytes hole, try to use */
        u32                     target;
+       __be64                  tun_id;
        struct fib_rule __rcu   *ctarget;
+       struct net              *fr_net;
+
+       atomic_t                refcnt;
+       u32                     pref;
+       int                     suppress_ifgroup;
+       int                     suppress_prefixlen;
        char                    iifname[IFNAMSIZ];
        char                    oifname[IFNAMSIZ];
        kuid_t                  uid_start;
        kuid_t                  uid_end;
        struct rcu_head         rcu;
-       struct net *            fr_net;
 };
 
 struct fib_lookup_arg {
@@ -34,7 +39,8 @@ struct fib_lookup_arg {
        void                    *result;
        struct fib_rule         *rule;
        int                     flags;
-#define FIB_LOOKUP_NOREF       1
+#define FIB_LOOKUP_NOREF               1
+#define FIB_LOOKUP_IGNORE_LINKSTATE    2
 };
 
 struct fib_rules_ops {
@@ -48,19 +54,20 @@ struct fib_rules_ops {
        int                     (*action)(struct fib_rule *,
                                          struct flowi *, int,
                                          struct fib_lookup_arg *);
+       bool                    (*suppress)(struct fib_rule *,
+                                           struct fib_lookup_arg *);
        int                     (*match)(struct fib_rule *,
                                         struct flowi *, int);
        int                     (*configure)(struct fib_rule *,
                                             struct sk_buff *,
                                             struct fib_rule_hdr *,
                                             struct nlattr **);
-       void                    (*delete)(struct fib_rule *);
+       int                     (*delete)(struct fib_rule *);
        int                     (*compare)(struct fib_rule *,
                                           struct fib_rule_hdr *,
                                           struct nlattr **);
        int                     (*fill)(struct fib_rule *, struct sk_buff *,
                                        struct fib_rule_hdr *);
-       u32                     (*default_pref)(struct fib_rules_ops *ops);
        size_t                  (*nlmsg_payload)(struct fib_rule *);
 
        /* Called after modifications to the rules set, must flush
@@ -84,24 +91,20 @@ struct fib_rules_ops {
        [FRA_TABLE]     = { .type = NLA_U32 }, \
        [FRA_GOTO]      = { .type = NLA_U32 }, \
        [FRA_UID_START] = { .type = NLA_U32 }, \
-       [FRA_UID_END]   = { .type = NLA_U32 }
+       [FRA_UID_END]   = { .type = NLA_U32 }, \
+       [FRA_SUPPRESS_PREFIXLEN] = { .type = NLA_U32 }, \
+       [FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 }, \
+       [FRA_GOTO]      = { .type = NLA_U32 }
 
 static inline void fib_rule_get(struct fib_rule *rule)
 {
        atomic_inc(&rule->refcnt);
 }
 
-static inline void fib_rule_put_rcu(struct rcu_head *head)
-{
-       struct fib_rule *rule = container_of(head, struct fib_rule, rcu);
-       release_net(rule->fr_net);
-       kfree(rule);
-}
-
 static inline void fib_rule_put(struct fib_rule *rule)
 {
        if (atomic_dec_and_test(&rule->refcnt))
-               call_rcu(&rule->rcu, fib_rule_put_rcu);
+               kfree_rcu(rule, rcu);
 }
 
 static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
@@ -111,14 +114,12 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
        return frh->table;
 }
 
-extern struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *, struct net *);
-extern void fib_rules_unregister(struct fib_rules_ops *);
+struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *,
+                                        struct net *);
+void fib_rules_unregister(struct fib_rules_ops *);
 
-extern int                     fib_rules_lookup(struct fib_rules_ops *,
-                                                struct flowi *, int flags,
-                                                struct fib_lookup_arg *);
-extern int                     fib_default_rule_add(struct fib_rules_ops *,
-                                                    u32 pref, u32 table,
-                                                    u32 flags);
-extern u32                     fib_default_rule_pref(struct fib_rules_ops *ops);
+int fib_rules_lookup(struct fib_rules_ops *, struct flowi *, int flags,
+                    struct fib_lookup_arg *);
+int fib_default_rule_add(struct fib_rules_ops *, u32 pref, u32 table,
+                        u32 flags);
 #endif