bridge: fix setting pvid for updated vlans
[project/netifd.git] / device.h
index dc410b425c9398a3f690a0d0f080c0c9f46a7675..db6dc3359138633d594f5673ce8ea42c475f94b8 100644 (file)
--- a/device.h
+++ b/device.h
@@ -54,6 +54,12 @@ enum {
        DEV_ATTR_NEIGHLOCKTIME,
        DEV_ATTR_ISOLATE,
        DEV_ATTR_IP6SEGMENTROUTING,
+       DEV_ATTR_DROP_V4_UNICAST_IN_L2_MULTICAST,
+       DEV_ATTR_DROP_V6_UNICAST_IN_L2_MULTICAST,
+       DEV_ATTR_DROP_GRATUITOUS_ARP,
+       DEV_ATTR_DROP_UNSOLICITED_NA,
+       DEV_ATTR_ARP_ACCEPT,
+       DEV_ATTR_AUTH,
        __DEV_ATTR_MAX,
 };
 
@@ -77,6 +83,7 @@ struct device_type {
                struct blob_attr *attr);
        void (*config_init)(struct device *);
        enum dev_change_type (*reload)(struct device *, struct blob_attr *);
+       void (*vlan_update)(struct device *);
        void (*dump_info)(struct device *, struct blob_buf *buf);
        void (*dump_stats)(struct device *, struct blob_buf *buf);
        int (*check_state)(struct device *);
@@ -95,7 +102,7 @@ enum {
        DEV_OPT_MLDVERSION              = (1 << 8),
        DEV_OPT_NEIGHREACHABLETIME      = (1 << 9),
        DEV_OPT_DEFAULT_MACADDR         = (1 << 10),
-       /* 1 bit hole */
+       DEV_OPT_AUTH                    = (1 << 11),
        DEV_OPT_MTU6                    = (1 << 12),
        DEV_OPT_DADTRANSMITS            = (1 << 13),
        DEV_OPT_MULTICAST_TO_UNICAST    = (1 << 14),
@@ -109,6 +116,11 @@ enum {
        DEV_OPT_NEIGHLOCKTIME           = (1 << 22),
        DEV_OPT_ISOLATE                 = (1 << 23),
        DEV_OPT_IP6SEGMENTROUTING       = (1 << 24),
+       DEV_OPT_DROP_V4_UNICAST_IN_L2_MULTICAST = (1 << 25),
+       DEV_OPT_DROP_V6_UNICAST_IN_L2_MULTICAST = (1 << 26),
+       DEV_OPT_DROP_GRATUITOUS_ARP     = (1 << 27),
+       DEV_OPT_DROP_UNSOLICITED_NA     = (1 << 28),
+       DEV_OPT_ARP_ACCEPT              = (1 << 29),
 };
 
 /* events broadcasted to all users of a device */
@@ -124,6 +136,7 @@ enum device_event {
        DEV_EVENT_UP,
        DEV_EVENT_DOWN,
 
+       DEV_EVENT_AUTH_UP,
        DEV_EVENT_LINK_UP,
        DEV_EVENT_LINK_DOWN,
 
@@ -177,6 +190,12 @@ struct device_settings {
        bool sendredirects;
        bool ip6segmentrouting;
        bool isolate;
+       bool drop_v4_unicast_in_l2_multicast;
+       bool drop_v6_unicast_in_l2_multicast;
+       bool drop_gratuitous_arp;
+       bool drop_unsolicited_na;
+       bool arp_accept;
+       bool auth;
 };
 
 /*
@@ -205,6 +224,7 @@ struct device {
        int active;
        /* DEV_EVENT_LINK_UP */
        bool link_active;
+       bool auth_status;
 
        bool external;
        bool disabled;
@@ -234,7 +254,7 @@ struct device {
 struct device_hotplug_ops {
        int (*prepare)(struct device *dev, struct device **bridge_dev);
        int (*add)(struct device *main, struct device *member, struct blob_attr *vlan);
-       int (*del)(struct device *main, struct device *member);
+       int (*del)(struct device *main, struct device *member, struct blob_attr *vlan);
 };
 
 enum bridge_vlan_flags {
@@ -258,6 +278,7 @@ struct bridge_vlan {
 
        uint16_t vid;
        bool local;
+       bool pending;
 };
 
 extern const struct uci_blob_param_list device_attr_list;
@@ -309,6 +330,8 @@ struct device *get_vlan_device_chain(const char *ifname, bool create);
 void alias_notify_device(const char *name, struct device *dev);
 struct device *device_alias_get(const char *name);
 
+void device_set_auth_status(struct device *dev, bool value);
+
 static inline void
 device_set_deferred(struct device *dev, bool value)
 {
@@ -323,6 +346,15 @@ device_set_disabled(struct device *dev, bool value)
        device_refresh_present(dev);
 }
 
+static inline bool
+device_link_active(struct device *dev)
+{
+       if (dev->settings.auth && !dev->auth_status)
+               return false;
+
+       return dev->link_active;
+}
+
 bool device_check_ip6segmentrouting(void);
 
 #endif