Lines Matching full:cfg

711 static int br_mdb_replace_group_sg(const struct br_mdb_config *cfg,  in br_mdb_replace_group_sg()  argument
720 pg->rt_protocol = cfg->rt_protocol; in br_mdb_replace_group_sg()
721 if (!(flags & MDB_PG_FLAGS_PERMANENT) && !cfg->src_entry) in br_mdb_replace_group_sg()
727 br_mdb_notify(cfg->br->dev, mp, pg, RTM_NEWMDB); in br_mdb_replace_group_sg()
732 static int br_mdb_add_group_sg(const struct br_mdb_config *cfg, in br_mdb_add_group_sg() argument
743 (p = mlock_dereference(*pp, cfg->br)) != NULL; in br_mdb_add_group_sg()
745 if (p->key.port == cfg->p) { in br_mdb_add_group_sg()
746 if (!(cfg->nlflags & NLM_F_REPLACE)) { in br_mdb_add_group_sg()
750 return br_mdb_replace_group_sg(cfg, mp, p, brmctx, in br_mdb_add_group_sg()
753 if ((unsigned long)p->key.port < (unsigned long)cfg->p) in br_mdb_add_group_sg()
757 p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL, in br_mdb_add_group_sg()
758 MCAST_INCLUDE, cfg->rt_protocol, extack); in br_mdb_add_group_sg()
763 if (!(flags & MDB_PG_FLAGS_PERMANENT) && !cfg->src_entry) in br_mdb_add_group_sg()
766 br_mdb_notify(cfg->br->dev, mp, p, RTM_NEWMDB); in br_mdb_add_group_sg()
771 if (br_multicast_should_handle_mode(brmctx, cfg->group.proto)) { in br_mdb_add_group_sg()
777 star_mp = br_mdb_ip_get(cfg->br, &star_group); in br_mdb_add_group_sg()
785 static int br_mdb_add_group_src_fwd(const struct br_mdb_config *cfg, in br_mdb_add_group_src_fwd() argument
795 sg_ip = cfg->group; in br_mdb_add_group_src_fwd()
797 sgmp = br_multicast_new_group(cfg->br, &sg_ip); in br_mdb_add_group_src_fwd()
803 if (cfg->entry->state == MDB_PERMANENT) in br_mdb_add_group_src_fwd()
805 if (cfg->filter_mode == MCAST_EXCLUDE) in br_mdb_add_group_src_fwd()
809 sg_cfg.br = cfg->br; in br_mdb_add_group_src_fwd()
810 sg_cfg.p = cfg->p; in br_mdb_add_group_src_fwd()
811 sg_cfg.entry = cfg->entry; in br_mdb_add_group_src_fwd()
815 sg_cfg.rt_protocol = cfg->rt_protocol; in br_mdb_add_group_src_fwd()
816 sg_cfg.nlflags = cfg->nlflags; in br_mdb_add_group_src_fwd()
820 static int br_mdb_add_group_src(const struct br_mdb_config *cfg, in br_mdb_add_group_src() argument
837 } else if (!(cfg->nlflags & NLM_F_REPLACE)) { in br_mdb_add_group_src()
842 if (cfg->filter_mode == MCAST_INCLUDE && in br_mdb_add_group_src()
843 cfg->entry->state == MDB_TEMPORARY) in br_mdb_add_group_src()
849 err = br_mdb_add_group_src_fwd(cfg, &src->addr, brmctx, extack); in br_mdb_add_group_src()
873 static int br_mdb_add_group_srcs(const struct br_mdb_config *cfg, in br_mdb_add_group_srcs() argument
880 for (i = 0; i < cfg->num_src_entries; i++) { in br_mdb_add_group_srcs()
881 err = br_mdb_add_group_src(cfg, pg, brmctx, in br_mdb_add_group_srcs()
882 &cfg->src_entries[i], extack); in br_mdb_add_group_srcs()
891 br_mdb_del_group_src(pg, &cfg->src_entries[i]); in br_mdb_add_group_srcs()
895 static int br_mdb_replace_group_srcs(const struct br_mdb_config *cfg, in br_mdb_replace_group_srcs() argument
907 err = br_mdb_add_group_srcs(cfg, pg, brmctx, extack); in br_mdb_replace_group_srcs()
924 static int br_mdb_replace_group_star_g(const struct br_mdb_config *cfg, in br_mdb_replace_group_star_g() argument
934 err = br_mdb_replace_group_srcs(cfg, pg, brmctx, extack); in br_mdb_replace_group_star_g()
939 pg->filter_mode = cfg->filter_mode; in br_mdb_replace_group_star_g()
940 pg->rt_protocol = cfg->rt_protocol; in br_mdb_replace_group_star_g()
942 cfg->filter_mode == MCAST_EXCLUDE) in br_mdb_replace_group_star_g()
948 br_mdb_notify(cfg->br->dev, mp, pg, RTM_NEWMDB); in br_mdb_replace_group_star_g()
950 if (br_multicast_should_handle_mode(brmctx, cfg->group.proto)) in br_mdb_replace_group_star_g()
951 br_multicast_star_g_handle_mode(pg, cfg->filter_mode); in br_mdb_replace_group_star_g()
956 static int br_mdb_add_group_star_g(const struct br_mdb_config *cfg, in br_mdb_add_group_star_g() argument
968 (p = mlock_dereference(*pp, cfg->br)) != NULL; in br_mdb_add_group_star_g()
970 if (p->key.port == cfg->p) { in br_mdb_add_group_star_g()
971 if (!(cfg->nlflags & NLM_F_REPLACE)) { in br_mdb_add_group_star_g()
975 return br_mdb_replace_group_star_g(cfg, mp, p, brmctx, in br_mdb_add_group_star_g()
978 if ((unsigned long)p->key.port < (unsigned long)cfg->p) in br_mdb_add_group_star_g()
982 p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL, in br_mdb_add_group_star_g()
983 cfg->filter_mode, cfg->rt_protocol, in br_mdb_add_group_star_g()
988 err = br_mdb_add_group_srcs(cfg, p, brmctx, extack); in br_mdb_add_group_star_g()
994 cfg->filter_mode == MCAST_EXCLUDE) in br_mdb_add_group_star_g()
997 br_mdb_notify(cfg->br->dev, mp, p, RTM_NEWMDB); in br_mdb_add_group_star_g()
1001 if (br_multicast_should_handle_mode(brmctx, cfg->group.proto) && in br_mdb_add_group_star_g()
1002 cfg->filter_mode == MCAST_EXCLUDE) in br_mdb_add_group_star_g()
1012 static int br_mdb_add_group(const struct br_mdb_config *cfg, in br_mdb_add_group() argument
1015 struct br_mdb_entry *entry = cfg->entry; in br_mdb_add_group()
1016 struct net_bridge_port *port = cfg->p; in br_mdb_add_group()
1018 struct net_bridge *br = cfg->br; in br_mdb_add_group()
1020 struct br_ip group = cfg->group; in br_mdb_add_group()
1048 return br_mdb_add_group_star_g(cfg, mp, brmctx, flags, extack); in br_mdb_add_group()
1050 return br_mdb_add_group_sg(cfg, mp, brmctx, flags, extack); in br_mdb_add_group()
1053 static int __br_mdb_add(const struct br_mdb_config *cfg, in __br_mdb_add() argument
1058 spin_lock_bh(&cfg->br->multicast_lock); in __br_mdb_add()
1059 ret = br_mdb_add_group(cfg, extack); in __br_mdb_add()
1060 spin_unlock_bh(&cfg->br->multicast_lock); in __br_mdb_add()
1092 struct br_mdb_config *cfg, in br_mdb_config_src_list_init() argument
1100 cfg->num_src_entries++; in br_mdb_config_src_list_init()
1102 if (cfg->num_src_entries >= PG_SRC_ENT_LIMIT) { in br_mdb_config_src_list_init()
1108 cfg->src_entries = kcalloc(cfg->num_src_entries, in br_mdb_config_src_list_init()
1110 if (!cfg->src_entries) in br_mdb_config_src_list_init()
1115 &cfg->src_entries[i], in br_mdb_config_src_list_init()
1116 cfg->entry->addr.proto, in br_mdb_config_src_list_init()
1126 kfree(cfg->src_entries); in br_mdb_config_src_list_init()
1130 static void br_mdb_config_src_list_fini(struct br_mdb_config *cfg) in br_mdb_config_src_list_fini() argument
1132 kfree(cfg->src_entries); in br_mdb_config_src_list_fini()
1136 struct br_mdb_config *cfg, in br_mdb_config_attrs_init() argument
1149 cfg->entry->addr.proto, extack)) in br_mdb_config_attrs_init()
1152 __mdb_entry_to_br_ip(cfg->entry, &cfg->group, mdb_attrs); in br_mdb_config_attrs_init()
1155 if (!cfg->p) { in br_mdb_config_attrs_init()
1159 if (!br_multicast_is_star_g(&cfg->group)) { in br_mdb_config_attrs_init()
1163 cfg->filter_mode = nla_get_u8(mdb_attrs[MDBE_ATTR_GROUP_MODE]); in br_mdb_config_attrs_init()
1165 cfg->filter_mode = MCAST_EXCLUDE; in br_mdb_config_attrs_init()
1169 if (!cfg->p) { in br_mdb_config_attrs_init()
1173 if (!br_multicast_is_star_g(&cfg->group)) { in br_mdb_config_attrs_init()
1182 cfg, extack); in br_mdb_config_attrs_init()
1187 if (!cfg->num_src_entries && cfg->filter_mode == MCAST_INCLUDE) { in br_mdb_config_attrs_init()
1193 if (!cfg->p) { in br_mdb_config_attrs_init()
1197 cfg->rt_protocol = nla_get_u8(mdb_attrs[MDBE_ATTR_RTPROT]); in br_mdb_config_attrs_init()
1203 static int br_mdb_config_init(struct br_mdb_config *cfg, struct net_device *dev, in br_mdb_config_init() argument
1209 memset(cfg, 0, sizeof(*cfg)); in br_mdb_config_init()
1210 cfg->filter_mode = MCAST_EXCLUDE; in br_mdb_config_init()
1211 cfg->rt_protocol = RTPROT_STATIC; in br_mdb_config_init()
1212 cfg->nlflags = nlmsg_flags; in br_mdb_config_init()
1214 cfg->br = netdev_priv(dev); in br_mdb_config_init()
1216 if (!netif_running(cfg->br->dev)) { in br_mdb_config_init()
1221 if (!br_opt_get(cfg->br, BROPT_MULTICAST_ENABLED)) { in br_mdb_config_init()
1226 cfg->entry = nla_data(tb[MDBA_SET_ENTRY]); in br_mdb_config_init()
1228 if (cfg->entry->ifindex != cfg->br->dev->ifindex) { in br_mdb_config_init()
1231 pdev = __dev_get_by_index(net, cfg->entry->ifindex); in br_mdb_config_init()
1237 cfg->p = br_port_get_rtnl(pdev); in br_mdb_config_init()
1238 if (!cfg->p) { in br_mdb_config_init()
1243 if (cfg->p->br != cfg->br) { in br_mdb_config_init()
1249 if (cfg->entry->addr.proto == htons(ETH_P_IP) && in br_mdb_config_init()
1250 ipv4_is_zeronet(cfg->entry->addr.u.ip4)) { in br_mdb_config_init()
1256 return br_mdb_config_attrs_init(tb[MDBA_SET_ENTRY_ATTRS], cfg, in br_mdb_config_init()
1259 __mdb_entry_to_br_ip(cfg->entry, &cfg->group, NULL); in br_mdb_config_init()
1264 static void br_mdb_config_fini(struct br_mdb_config *cfg) in br_mdb_config_fini() argument
1266 br_mdb_config_src_list_fini(cfg); in br_mdb_config_fini()
1274 struct br_mdb_config cfg; in br_mdb_add() local
1277 err = br_mdb_config_init(&cfg, dev, tb, nlmsg_flags, extack); in br_mdb_add()
1283 if (!cfg.p && !br_group_is_l2(&cfg.group)) { in br_mdb_add()
1285 if (cfg.entry->state) { in br_mdb_add()
1289 if (!br_multicast_is_star_g(&cfg.group)) { in br_mdb_add()
1295 if (br_group_is_l2(&cfg.group) && cfg.entry->state != MDB_PERMANENT) { in br_mdb_add()
1300 if (cfg.p) { in br_mdb_add()
1301 if (cfg.p->state == BR_STATE_DISABLED && cfg.entry->state != MDB_PERMANENT) { in br_mdb_add()
1305 vg = nbp_vlan_group(cfg.p); in br_mdb_add()
1307 vg = br_vlan_group(cfg.br); in br_mdb_add()
1313 if (br_vlan_enabled(cfg.br->dev) && vg && cfg.entry->vid == 0) { in br_mdb_add()
1315 cfg.entry->vid = v->vid; in br_mdb_add()
1316 cfg.group.vid = v->vid; in br_mdb_add()
1317 err = __br_mdb_add(&cfg, extack); in br_mdb_add()
1322 err = __br_mdb_add(&cfg, extack); in br_mdb_add()
1326 br_mdb_config_fini(&cfg); in br_mdb_add()
1330 static int __br_mdb_del(const struct br_mdb_config *cfg) in __br_mdb_del() argument
1332 struct br_mdb_entry *entry = cfg->entry; in __br_mdb_del()
1333 struct net_bridge *br = cfg->br; in __br_mdb_del()
1337 struct br_ip ip = cfg->group; in __br_mdb_del()
1376 struct br_mdb_config cfg; in br_mdb_del() local
1379 err = br_mdb_config_init(&cfg, dev, tb, 0, extack); in br_mdb_del()
1383 if (cfg.p) in br_mdb_del()
1384 vg = nbp_vlan_group(cfg.p); in br_mdb_del()
1386 vg = br_vlan_group(cfg.br); in br_mdb_del()
1391 if (br_vlan_enabled(cfg.br->dev) && vg && cfg.entry->vid == 0) { in br_mdb_del()
1393 cfg.entry->vid = v->vid; in br_mdb_del()
1394 cfg.group.vid = v->vid; in br_mdb_del()
1395 err = __br_mdb_del(&cfg); in br_mdb_del()
1398 err = __br_mdb_del(&cfg); in br_mdb_del()
1401 br_mdb_config_fini(&cfg); in br_mdb_del()