l2tp: prevent creation of sessions on terminated tunnels
[pandora-kernel.git] / net / l2tp / l2tp_core.h
index ec3ac0e..1bc5859 100644 (file)
@@ -159,6 +159,10 @@ struct l2tp_tunnel {
        int                     magic;          /* Should be L2TP_TUNNEL_MAGIC */
        struct rcu_head rcu;
        rwlock_t                hlist_lock;     /* protect session_hlist */
+       bool                    acpt_newsess;   /* Indicates whether this
+                                                * tunnel accepts new sessions.
+                                                * Protected by hlist_lock.
+                                                */
        struct hlist_head       session_hlist[L2TP_HASH_SIZE];
                                                /* hashed list of sessions,
                                                 * hashed by id */
@@ -222,6 +226,9 @@ out:
        return tunnel;
 }
 
+struct l2tp_tunnel *l2tp_tunnel_get(const struct net *net, u32 tunnel_id);
+void l2tp_tunnel_free(struct l2tp_tunnel *tunnel);
+
 struct l2tp_session *l2tp_session_get(const struct net *net,
                                      struct l2tp_tunnel *tunnel,
                                      u32 session_id, bool do_ref);
@@ -248,6 +255,17 @@ extern int l2tp_nl_register_ops(enum l2tp_pwtype pw_type, const struct l2tp_nl_c
 extern void l2tp_nl_unregister_ops(enum l2tp_pwtype pw_type);
 int l2tp_ioctl(struct sock *sk, int cmd, unsigned long arg);
 
+static inline void l2tp_tunnel_inc_refcount(struct l2tp_tunnel *tunnel)
+{
+       atomic_inc(&tunnel->ref_count);
+}
+
+static inline void l2tp_tunnel_dec_refcount(struct l2tp_tunnel *tunnel)
+{
+       if (atomic_dec_and_test(&tunnel->ref_count))
+               l2tp_tunnel_free(tunnel);
+}
+
 /* Session reference counts. Incremented when code obtains a reference
  * to a session.
  */