diff options
Diffstat (limited to 'net/netlabel/netlabel_mgmt.c')
| -rw-r--r-- | net/netlabel/netlabel_mgmt.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c index c5384ffc6146..dd1c37d7acbc 100644 --- a/net/netlabel/netlabel_mgmt.c +++ b/net/netlabel/netlabel_mgmt.c | |||
| @@ -104,7 +104,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, | |||
| 104 | ret_val = -ENOMEM; | 104 | ret_val = -ENOMEM; |
| 105 | goto add_failure; | 105 | goto add_failure; |
| 106 | } | 106 | } |
| 107 | entry->type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]); | 107 | entry->def.type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]); |
| 108 | if (info->attrs[NLBL_MGMT_A_DOMAIN]) { | 108 | if (info->attrs[NLBL_MGMT_A_DOMAIN]) { |
| 109 | size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]); | 109 | size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]); |
| 110 | entry->domain = kmalloc(tmp_size, GFP_KERNEL); | 110 | entry->domain = kmalloc(tmp_size, GFP_KERNEL); |
| @@ -116,12 +116,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, | |||
| 116 | info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size); | 116 | info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | /* NOTE: internally we allow/use a entry->type value of | 119 | /* NOTE: internally we allow/use a entry->def.type value of |
| 120 | * NETLBL_NLTYPE_ADDRSELECT but we don't currently allow users | 120 | * NETLBL_NLTYPE_ADDRSELECT but we don't currently allow users |
| 121 | * to pass that as a protocol value because we need to know the | 121 | * to pass that as a protocol value because we need to know the |
| 122 | * "real" protocol */ | 122 | * "real" protocol */ |
| 123 | 123 | ||
| 124 | switch (entry->type) { | 124 | switch (entry->def.type) { |
| 125 | case NETLBL_NLTYPE_UNLABELED: | 125 | case NETLBL_NLTYPE_UNLABELED: |
| 126 | break; | 126 | break; |
| 127 | case NETLBL_NLTYPE_CIPSOV4: | 127 | case NETLBL_NLTYPE_CIPSOV4: |
| @@ -132,7 +132,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, | |||
| 132 | cipsov4 = cipso_v4_doi_getdef(tmp_val); | 132 | cipsov4 = cipso_v4_doi_getdef(tmp_val); |
| 133 | if (cipsov4 == NULL) | 133 | if (cipsov4 == NULL) |
| 134 | goto add_failure; | 134 | goto add_failure; |
| 135 | entry->type_def.cipsov4 = cipsov4; | 135 | entry->def.cipso = cipsov4; |
| 136 | break; | 136 | break; |
| 137 | default: | 137 | default: |
| 138 | goto add_failure; | 138 | goto add_failure; |
| @@ -172,9 +172,9 @@ static int netlbl_mgmt_add_common(struct genl_info *info, | |||
| 172 | map->list.addr = addr->s_addr & mask->s_addr; | 172 | map->list.addr = addr->s_addr & mask->s_addr; |
| 173 | map->list.mask = mask->s_addr; | 173 | map->list.mask = mask->s_addr; |
| 174 | map->list.valid = 1; | 174 | map->list.valid = 1; |
| 175 | map->type = entry->type; | 175 | map->def.type = entry->def.type; |
| 176 | if (cipsov4) | 176 | if (cipsov4) |
| 177 | map->type_def.cipsov4 = cipsov4; | 177 | map->def.cipso = cipsov4; |
| 178 | 178 | ||
| 179 | ret_val = netlbl_af4list_add(&map->list, &addrmap->list4); | 179 | ret_val = netlbl_af4list_add(&map->list, &addrmap->list4); |
| 180 | if (ret_val != 0) { | 180 | if (ret_val != 0) { |
| @@ -182,8 +182,8 @@ static int netlbl_mgmt_add_common(struct genl_info *info, | |||
| 182 | goto add_failure; | 182 | goto add_failure; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | entry->type = NETLBL_NLTYPE_ADDRSELECT; | 185 | entry->def.type = NETLBL_NLTYPE_ADDRSELECT; |
| 186 | entry->type_def.addrsel = addrmap; | 186 | entry->def.addrsel = addrmap; |
| 187 | #if IS_ENABLED(CONFIG_IPV6) | 187 | #if IS_ENABLED(CONFIG_IPV6) |
| 188 | } else if (info->attrs[NLBL_MGMT_A_IPV6ADDR]) { | 188 | } else if (info->attrs[NLBL_MGMT_A_IPV6ADDR]) { |
| 189 | struct in6_addr *addr; | 189 | struct in6_addr *addr; |
| @@ -223,7 +223,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, | |||
| 223 | map->list.addr.s6_addr32[3] &= mask->s6_addr32[3]; | 223 | map->list.addr.s6_addr32[3] &= mask->s6_addr32[3]; |
| 224 | map->list.mask = *mask; | 224 | map->list.mask = *mask; |
| 225 | map->list.valid = 1; | 225 | map->list.valid = 1; |
| 226 | map->type = entry->type; | 226 | map->def.type = entry->def.type; |
| 227 | 227 | ||
| 228 | ret_val = netlbl_af6list_add(&map->list, &addrmap->list6); | 228 | ret_val = netlbl_af6list_add(&map->list, &addrmap->list6); |
| 229 | if (ret_val != 0) { | 229 | if (ret_val != 0) { |
| @@ -231,8 +231,8 @@ static int netlbl_mgmt_add_common(struct genl_info *info, | |||
| 231 | goto add_failure; | 231 | goto add_failure; |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | entry->type = NETLBL_NLTYPE_ADDRSELECT; | 234 | entry->def.type = NETLBL_NLTYPE_ADDRSELECT; |
| 235 | entry->type_def.addrsel = addrmap; | 235 | entry->def.addrsel = addrmap; |
| 236 | #endif /* IPv6 */ | 236 | #endif /* IPv6 */ |
| 237 | } | 237 | } |
| 238 | 238 | ||
| @@ -281,14 +281,13 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb, | |||
| 281 | return ret_val; | 281 | return ret_val; |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | switch (entry->type) { | 284 | switch (entry->def.type) { |
| 285 | case NETLBL_NLTYPE_ADDRSELECT: | 285 | case NETLBL_NLTYPE_ADDRSELECT: |
| 286 | nla_a = nla_nest_start(skb, NLBL_MGMT_A_SELECTORLIST); | 286 | nla_a = nla_nest_start(skb, NLBL_MGMT_A_SELECTORLIST); |
| 287 | if (nla_a == NULL) | 287 | if (nla_a == NULL) |
| 288 | return -ENOMEM; | 288 | return -ENOMEM; |
| 289 | 289 | ||
| 290 | netlbl_af4list_foreach_rcu(iter4, | 290 | netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4) { |
| 291 | &entry->type_def.addrsel->list4) { | ||
| 292 | struct netlbl_domaddr4_map *map4; | 291 | struct netlbl_domaddr4_map *map4; |
| 293 | struct in_addr addr_struct; | 292 | struct in_addr addr_struct; |
| 294 | 293 | ||
| @@ -310,13 +309,13 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb, | |||
| 310 | return ret_val; | 309 | return ret_val; |
| 311 | map4 = netlbl_domhsh_addr4_entry(iter4); | 310 | map4 = netlbl_domhsh_addr4_entry(iter4); |
| 312 | ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, | 311 | ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, |
| 313 | map4->type); | 312 | map4->def.type); |
| 314 | if (ret_val != 0) | 313 | if (ret_val != 0) |
| 315 | return ret_val; | 314 | return ret_val; |
| 316 | switch (map4->type) { | 315 | switch (map4->def.type) { |
| 317 | case NETLBL_NLTYPE_CIPSOV4: | 316 | case NETLBL_NLTYPE_CIPSOV4: |
| 318 | ret_val = nla_put_u32(skb, NLBL_MGMT_A_CV4DOI, | 317 | ret_val = nla_put_u32(skb, NLBL_MGMT_A_CV4DOI, |
| 319 | map4->type_def.cipsov4->doi); | 318 | map4->def.cipso->doi); |
| 320 | if (ret_val != 0) | 319 | if (ret_val != 0) |
| 321 | return ret_val; | 320 | return ret_val; |
| 322 | break; | 321 | break; |
| @@ -325,8 +324,7 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb, | |||
| 325 | nla_nest_end(skb, nla_b); | 324 | nla_nest_end(skb, nla_b); |
| 326 | } | 325 | } |
| 327 | #if IS_ENABLED(CONFIG_IPV6) | 326 | #if IS_ENABLED(CONFIG_IPV6) |
| 328 | netlbl_af6list_foreach_rcu(iter6, | 327 | netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6) { |
| 329 | &entry->type_def.addrsel->list6) { | ||
| 330 | struct netlbl_domaddr6_map *map6; | 328 | struct netlbl_domaddr6_map *map6; |
| 331 | 329 | ||
| 332 | nla_b = nla_nest_start(skb, NLBL_MGMT_A_ADDRSELECTOR); | 330 | nla_b = nla_nest_start(skb, NLBL_MGMT_A_ADDRSELECTOR); |
| @@ -345,7 +343,7 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb, | |||
| 345 | return ret_val; | 343 | return ret_val; |
| 346 | map6 = netlbl_domhsh_addr6_entry(iter6); | 344 | map6 = netlbl_domhsh_addr6_entry(iter6); |
| 347 | ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, | 345 | ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, |
| 348 | map6->type); | 346 | map6->def.type); |
| 349 | if (ret_val != 0) | 347 | if (ret_val != 0) |
| 350 | return ret_val; | 348 | return ret_val; |
| 351 | 349 | ||
| @@ -356,14 +354,14 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb, | |||
| 356 | nla_nest_end(skb, nla_a); | 354 | nla_nest_end(skb, nla_a); |
| 357 | break; | 355 | break; |
| 358 | case NETLBL_NLTYPE_UNLABELED: | 356 | case NETLBL_NLTYPE_UNLABELED: |
| 359 | ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, entry->type); | 357 | ret_val = nla_put_u32(skb,NLBL_MGMT_A_PROTOCOL,entry->def.type); |
| 360 | break; | 358 | break; |
| 361 | case NETLBL_NLTYPE_CIPSOV4: | 359 | case NETLBL_NLTYPE_CIPSOV4: |
| 362 | ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, entry->type); | 360 | ret_val = nla_put_u32(skb,NLBL_MGMT_A_PROTOCOL,entry->def.type); |
| 363 | if (ret_val != 0) | 361 | if (ret_val != 0) |
| 364 | return ret_val; | 362 | return ret_val; |
| 365 | ret_val = nla_put_u32(skb, NLBL_MGMT_A_CV4DOI, | 363 | ret_val = nla_put_u32(skb, NLBL_MGMT_A_CV4DOI, |
| 366 | entry->type_def.cipsov4->doi); | 364 | entry->def.cipso->doi); |
| 367 | break; | 365 | break; |
| 368 | } | 366 | } |
| 369 | 367 | ||
