[package] base-files, ppp: fix interface shutdown
[openwrt.git] / target / linux / generic-2.6 / files / drivers / net / phy / swconfig.c
index 8bae667..376dec1 100644 (file)
@@ -133,9 +133,19 @@ swconfig_apply_config(struct switch_dev *dev, const struct switch_attr *attr, st
        return dev->apply_config(dev);
 }
 
+static int
+swconfig_reset_switch(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
+{
+       /* don't complain if not supported by the switch driver */
+       if (!dev->reset_switch)
+               return 0;
+
+       return dev->reset_switch(dev);
+}
 
 enum global_defaults {
        GLOBAL_APPLY,
+       GLOBAL_RESET,
 };
 
 enum vlan_defaults {
@@ -152,6 +162,12 @@ static struct switch_attr default_global[] = {
                .name = "apply",
                .description = "Activate changes in the hardware",
                .set = swconfig_apply_config,
+       },
+       [GLOBAL_RESET] = {
+               .type = SWITCH_TYPE_NOVAL,
+               .name = "reset",
+               .description = "Reset the switch",
+               .set = swconfig_reset_switch,
        }
 };
 
@@ -190,6 +206,7 @@ static void swconfig_defaults_init(struct switch_dev *dev)
 
        /* always present, can be no-op */
        set_bit(GLOBAL_APPLY, &dev->def_global);
+       set_bit(GLOBAL_RESET, &dev->def_global);
 }
 
 
@@ -446,6 +463,8 @@ swconfig_lookup_attr(struct switch_dev *dev, struct genl_info *info,
                if (!info->attrs[SWITCH_ATTR_OP_VLAN])
                        goto done;
                val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_VLAN]);
+               if (val->port_vlan >= dev->vlans)
+                       goto done;
                break;
        case SWITCH_CMD_SET_PORT:
        case SWITCH_CMD_GET_PORT:
@@ -456,6 +475,8 @@ swconfig_lookup_attr(struct switch_dev *dev, struct genl_info *info,
                if (!info->attrs[SWITCH_ATTR_OP_PORT])
                        goto done;
                val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_PORT]);
+               if (val->port_vlan >= dev->ports)
+                       goto done;
                break;
        default:
                WARN_ON(1);
@@ -740,6 +761,7 @@ swconfig_send_switch(struct sk_buff *msg, u32 pid, u32 seq, int flags,
        NLA_PUT_STRING(msg, SWITCH_ATTR_DEV_NAME, dev->devname);
        NLA_PUT_U32(msg, SWITCH_ATTR_VLANS, dev->vlans);
        NLA_PUT_U32(msg, SWITCH_ATTR_PORTS, dev->ports);
+       NLA_PUT_U32(msg, SWITCH_ATTR_CPU_PORT, dev->cpu_port);
 
        return genlmsg_end(msg, hdr);
 nla_put_failure:
This page took 0.02495 seconds and 4 git commands to generate.