| 1 | |
| 2 | |
| 3 | * Handle bridge arp/nd proxy/suppress
|
| 4 | *
|
| 5 | * Copyright (C) 2017 Cumulus Networks
|
| 6 | * Copyright (c) 2017 Roopa Prabhu <[email protected]>
|
| 7 | *
|
| 8 | * Authors:
|
| 9 | * Roopa Prabhu <[email protected]>
|
| 10 |
|
| 11 |
|
| 12 | #include <linux/kernel.h>
|
| 13 | #include <linux/netdevice.h>
|
| 14 | #include <linux/etherdevice.h>
|
| 15 | #include <linux/neighbour.h>
|
| 16 | #include <net/arp.h>
|
| 17 | #include <linux/if_vlan.h>
|
| 18 | #include <linux/inetdevice.h>
|
| 19 | #include <net/addrconf.h>
|
| 20 | #if IS_ENABLED(CONFIG_IPV6)
|
| 21 | #include <net/ip6_checksum.h>
|
| 22 | #include <net/ndisc.h>
|
| 23 | #endif
|
| 24 |
|
| 25 | #include "br_private.h"
|
| 26 |
|
| 27 | void br_recalculate_neigh_suppress_enabled(struct net_bridge *br)
|
| 28 | {
|
| 29 | struct net_bridge_port *p;
|
| 30 | bool neigh_suppress = false;
|
| 31 |
|
| 32 | list_for_each_entry(p, &br->port_list, list) {
|
| 33 | if (READ_ONCE(p->flags) & (BR_NEIGH_SUPPRESS | BR_NEIGH_VLAN_SUPPRESS)) {
|
| 34 | neigh_suppress = true;
|
| 35 | break;
|
| 36 | }
|
| 37 | }
|
| 38 |
|
| 39 | br_opt_toggle(br, BROPT_NEIGH_SUPPRESS_ENABLED, neigh_suppress);
|
| 40 | }
|
| 41 |
|
| 42 | #if IS_ENABLED(CONFIG_INET)
|
| 43 | static void br_arp_send(struct net_bridge *br, struct net_bridge_port *p,
|
| 44 | struct net_device *dev, __be32 dest_ip, __be32 src_ip,
|
| 45 | const unsigned char *dest_hw,
|
| 46 | const unsigned char *src_hw,
|
| 47 | const unsigned char *target_hw,
|
| 48 | __be16 vlan_proto, u16 vlan_tci)
|
| 49 | {
|
| 50 | struct net_bridge_vlan_group *vg;
|
| 51 | struct sk_buff *skb;
|
| 52 | u16 pvid;
|
| 53 |
|
| 54 | netdev_dbg(dev, "arp send dev %s dst %pI4 dst_hw %pM src %pI4 src_hw %pM\n",
|
| 55 | dev->name, &dest_ip, dest_hw, &src_ip, src_hw);
|
| 56 |
|
| 57 | if (!vlan_tci) {
|
| 58 | arp_send(ARPOP_REPLY, ETH_P_ARP, dest_ip, dev, src_ip,
|
| 59 | dest_hw, src_hw, target_hw);
|
| 60 | return;
|
| 61 | }
|
| 62 |
|
| 63 | skb = arp_create(ARPOP_REPLY, ETH_P_ARP, dest_ip, dev, src_ip,
|
| 64 | dest_hw, src_hw, target_hw);
|
| 65 | if (!skb)
|
| 66 | return;
|
| 67 |
|
| 68 | if (p)
|
| 69 | vg = nbp_vlan_group_rcu(p);
|
| 70 | else
|
| 71 | vg = br_vlan_group_rcu(br);
|
| 72 | pvid = br_get_pvid(vg);
|
| 73 | if (pvid == (vlan_tci & VLAN_VID_MASK))
|
| 74 | vlan_tci = 0;
|
| 75 |
|
| 76 | if (vlan_tci)
|
| 77 | __vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
|
| 78 |
|
| 79 | if (p) {
|
| 80 | arp_xmit(skb);
|
| 81 | } else {
|
| 82 | skb_reset_mac_header(skb);
|
| 83 | __skb_pull(skb, skb_network_offset(skb));
|
| 84 | skb->ip_summed = CHECKSUM_UNNECESSARY;
|
| 85 | skb->pkt_type = PACKET_HOST;
|
| 86 |
|
| 87 | netif_rx(skb);
|
| 88 | }
|
| 89 | }
|
| 90 |
|
| 91 | static int br_chk_addr_ip(struct net_device *dev,
|
| 92 | struct netdev_nested_priv *priv)
|
| 93 | {
|
| 94 | __be32 ip = *(__be32 *)priv->data;
|
| 95 | struct in_device *in_dev;
|
| 96 | __be32 addr = 0;
|
| 97 |
|
| 98 | in_dev = __in_dev_get_rcu(dev);
|
| 99 | if (in_dev)
|
| 100 | addr = inet_confirm_addr(dev_net(dev), in_dev, 0, ip,
|
| 101 | RT_SCOPE_HOST);
|
| 102 |
|
| 103 | if (addr == ip)
|
| 104 | return 1;
|
| 105 |
|
| 106 | return 0;
|
| 107 | }
|
| 108 |
|
| 109 | static bool br_is_local_ip(struct net_device *dev, __be32 ip)
|
| 110 | {
|
| 111 | struct netdev_nested_priv priv = {
|
| 112 | .data = (void *)&ip,
|
| 113 | };
|
| 114 |
|
| 115 | if (br_chk_addr_ip(dev, &priv))
|
| 116 | return true;
|
| 117 |
|
| 118 |
|
| 119 | if (netdev_walk_all_upper_dev_rcu(dev, br_chk_addr_ip, &priv))
|
| 120 | return true;
|
| 121 |
|
| 122 | return false;
|
| 123 | }
|
| 124 |
|
| 125 | void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
|
| 126 | u16 vid, struct net_bridge_port *p)
|
| 127 | {
|
| 128 | struct net_device *dev = br->dev;
|
| 129 | struct net_device *vlandev = dev;
|
| 130 | struct neighbour *n;
|
| 131 | struct arphdr *parp;
|
| 132 | u8 *arpptr, *sha;
|
| 133 | __be32 sip, tip;
|
| 134 |
|
| 135 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = 0;
|
| 136 | BR_INPUT_SKB_CB(skb)->grat_arp = 0;
|
| 137 |
|
| 138 | if ((dev->flags & IFF_NOARP) ||
|
| 139 | !pskb_may_pull(skb, arp_hdr_len(dev)))
|
| 140 | return;
|
| 141 |
|
| 142 | parp = arp_hdr(skb);
|
| 143 |
|
| 144 | if (parp->ar_pro != htons(ETH_P_IP) ||
|
| 145 | parp->ar_hln != dev->addr_len ||
|
| 146 | parp->ar_pln != 4)
|
| 147 | return;
|
| 148 |
|
| 149 | arpptr = (u8 *)parp + sizeof(struct arphdr);
|
| 150 | sha = arpptr;
|
| 151 | arpptr += dev->addr_len;
|
| 152 | memcpy(&sip, arpptr, sizeof(sip));
|
| 153 | arpptr += sizeof(sip);
|
| 154 | arpptr += dev->addr_len;
|
| 155 | memcpy(&tip, arpptr, sizeof(tip));
|
| 156 |
|
| 157 | if (ipv4_is_loopback(tip) ||
|
| 158 | ipv4_is_multicast(tip))
|
| 159 | return;
|
| 160 |
|
| 161 | if (br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED)) {
|
| 162 | if (br_is_neigh_suppress_enabled(p, vid))
|
| 163 | return;
|
| 164 | if (is_unicast_ether_addr(eth_hdr(skb)->h_dest) &&
|
| 165 | parp->ar_op == htons(ARPOP_REQUEST))
|
| 166 | return;
|
| 167 | if (parp->ar_op != htons(ARPOP_RREQUEST) &&
|
| 168 | parp->ar_op != htons(ARPOP_RREPLY) &&
|
| 169 | sip == tip) {
|
| 170 |
|
| 171 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
|
| 172 | BR_INPUT_SKB_CB(skb)->grat_arp = 1;
|
| 173 | return;
|
| 174 | }
|
| 175 | }
|
| 176 |
|
| 177 | if (parp->ar_op != htons(ARPOP_REQUEST))
|
| 178 | return;
|
| 179 |
|
| 180 | if (vid != 0) {
|
| 181 | vlandev = __vlan_find_dev_deep_rcu(br->dev, skb->vlan_proto,
|
| 182 | vid);
|
| 183 | if (!vlandev)
|
| 184 | return;
|
| 185 | }
|
| 186 |
|
| 187 | if (br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED) &&
|
| 188 | br_is_local_ip(vlandev, tip)) {
|
| 189 | |
| 190 | * and don't forward to neigh suppress ports
|
| 191 |
|
| 192 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
|
| 193 | return;
|
| 194 | }
|
| 195 |
|
| 196 | n = neigh_lookup(&arp_tbl, &tip, vlandev);
|
| 197 | if (n) {
|
| 198 | struct net_bridge_fdb_entry *f;
|
| 199 | u8 ha[ETH_ALEN] __aligned(2);
|
| 200 |
|
| 201 | if (!(READ_ONCE(n->nud_state) & NUD_VALID)) {
|
| 202 | neigh_release(n);
|
| 203 | return;
|
| 204 | }
|
| 205 |
|
| 206 | neigh_ha_snapshot(ha, n, n->dev);
|
| 207 | f = br_fdb_find_rcu(br, ha, vid);
|
| 208 | if (f) {
|
| 209 | const struct net_bridge_port *dst = READ_ONCE(f->dst);
|
| 210 | bool replied = false;
|
| 211 |
|
| 212 | if ((p && test_bit(BR_PROXYARP_BIT, &p->flags)) ||
|
| 213 | (dst && test_bit(BR_PROXYARP_WIFI_BIT, &dst->flags)) ||
|
| 214 | br_is_neigh_suppress_enabled(dst, vid)) {
|
| 215 | if (!vid)
|
| 216 | br_arp_send(br, p, skb->dev, sip, tip,
|
| 217 | sha, ha, sha, 0, 0);
|
| 218 | else
|
| 219 | br_arp_send(br, p, skb->dev, sip, tip,
|
| 220 | sha, ha, sha,
|
| 221 | skb->vlan_proto,
|
| 222 | skb_vlan_tag_get(skb));
|
| 223 | replied = true;
|
| 224 | }
|
| 225 |
|
| 226 | |
| 227 | * mac, indicate to arp replied
|
| 228 |
|
| 229 | if (replied ||
|
| 230 | br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED))
|
| 231 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
|
| 232 | }
|
| 233 |
|
| 234 | neigh_release(n);
|
| 235 | }
|
| 236 | }
|
| 237 | #endif
|
| 238 |
|
| 239 | #if IS_ENABLED(CONFIG_IPV6)
|
| 240 | |
| 241 | * option parsing; returns the nd_msg, or NULL on failure.
|
| 242 |
|
| 243 | struct nd_msg *br_is_nd_neigh_msg(struct sk_buff *skb)
|
| 244 | {
|
| 245 | if (ndisc_check_ns_na(skb))
|
| 246 | return NULL;
|
| 247 |
|
| 248 | if (skb_linearize(skb))
|
| 249 | return NULL;
|
| 250 |
|
| 251 | return (struct nd_msg *)skb_transport_header(skb);
|
| 252 | }
|
| 253 |
|
| 254 | static void br_nd_send(struct net_bridge *br, struct net_bridge_port *p,
|
| 255 | struct sk_buff *request, struct neighbour *n, u8 *ha,
|
| 256 | __be16 vlan_proto, u16 vlan_tci)
|
| 257 | {
|
| 258 | struct net_device *dev = request->dev;
|
| 259 | struct net_bridge_vlan_group *vg;
|
| 260 | struct ndisc_options ndopts;
|
| 261 | struct nd_msg *na, *ns;
|
| 262 | struct sk_buff *reply;
|
| 263 | struct ipv6hdr *pip6;
|
| 264 | int na_olen = 8;
|
| 265 | int ns_olen;
|
| 266 | u8 *daddr;
|
| 267 | bool dad;
|
| 268 | u16 pvid;
|
| 269 | int len;
|
| 270 |
|
| 271 | if (!dev)
|
| 272 | return;
|
| 273 |
|
| 274 | len = LL_RESERVED_SPACE(dev) + sizeof(struct ipv6hdr) +
|
| 275 | sizeof(*na) + na_olen + dev->needed_tailroom;
|
| 276 |
|
| 277 | reply = alloc_skb(len, GFP_ATOMIC);
|
| 278 | if (!reply)
|
| 279 | return;
|
| 280 |
|
| 281 | reply->protocol = htons(ETH_P_IPV6);
|
| 282 | reply->dev = dev;
|
| 283 | skb_reserve(reply, LL_RESERVED_SPACE(dev));
|
| 284 | skb_push(reply, sizeof(struct ethhdr));
|
| 285 | skb_set_mac_header(reply, 0);
|
| 286 |
|
| 287 | daddr = eth_hdr(request)->h_source;
|
| 288 | ns = (struct nd_msg *)skb_transport_header(request);
|
| 289 |
|
| 290 | |
| 291 | * trailing L2 padding in the skb is not parsed as ND options.
|
| 292 |
|
| 293 | ns_olen = ntohs(ipv6_hdr(request)->payload_len) - sizeof(*ns);
|
| 294 | if (!ndisc_parse_options(dev, ns->opt, ns_olen, &ndopts)) {
|
| 295 | kfree_skb(reply);
|
| 296 | return;
|
| 297 | }
|
| 298 |
|
| 299 | if (ndopts.nd_opts_src_lladdr) {
|
| 300 | u8 *lladdr;
|
| 301 |
|
| 302 | lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, dev);
|
| 303 | if (lladdr)
|
| 304 | daddr = lladdr;
|
| 305 | }
|
| 306 |
|
| 307 | dad = ipv6_addr_any(&ipv6_hdr(request)->saddr);
|
| 308 |
|
| 309 |
|
| 310 | if (dad)
|
| 311 | ipv6_eth_mc_map(&in6addr_linklocal_allnodes, eth_hdr(reply)->h_dest);
|
| 312 | else
|
| 313 | ether_addr_copy(eth_hdr(reply)->h_dest, daddr);
|
| 314 | ether_addr_copy(eth_hdr(reply)->h_source, ha);
|
| 315 | eth_hdr(reply)->h_proto = htons(ETH_P_IPV6);
|
| 316 | reply->protocol = htons(ETH_P_IPV6);
|
| 317 |
|
| 318 | skb_pull(reply, sizeof(struct ethhdr));
|
| 319 | skb_set_network_header(reply, 0);
|
| 320 | skb_put(reply, sizeof(struct ipv6hdr));
|
| 321 |
|
| 322 |
|
| 323 | pip6 = ipv6_hdr(reply);
|
| 324 | memset(pip6, 0, sizeof(struct ipv6hdr));
|
| 325 | pip6->version = 6;
|
| 326 | pip6->priority = ipv6_hdr(request)->priority;
|
| 327 | pip6->nexthdr = IPPROTO_ICMPV6;
|
| 328 | pip6->hop_limit = 255;
|
| 329 | pip6->daddr = dad ? in6addr_linklocal_allnodes : ipv6_hdr(request)->saddr;
|
| 330 | pip6->saddr = *(struct in6_addr *)n->primary_key;
|
| 331 |
|
| 332 | skb_pull(reply, sizeof(struct ipv6hdr));
|
| 333 | skb_set_transport_header(reply, 0);
|
| 334 |
|
| 335 | na = (struct nd_msg *)skb_put(reply, sizeof(*na) + na_olen);
|
| 336 |
|
| 337 |
|
| 338 | memset(na, 0, sizeof(*na) + na_olen);
|
| 339 | na->icmph.icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT;
|
| 340 | na->icmph.icmp6_router = (n->flags & NTF_ROUTER) ? 1 : 0;
|
| 341 | na->icmph.icmp6_override = 1;
|
| 342 | na->icmph.icmp6_solicited = dad ? 0 : 1;
|
| 343 | na->target = ns->target;
|
| 344 | ether_addr_copy(&na->opt[2], ha);
|
| 345 | na->opt[0] = ND_OPT_TARGET_LL_ADDR;
|
| 346 | na->opt[1] = na_olen >> 3;
|
| 347 |
|
| 348 | na->icmph.icmp6_cksum = csum_ipv6_magic(&pip6->saddr,
|
| 349 | &pip6->daddr,
|
| 350 | sizeof(*na) + na_olen,
|
| 351 | IPPROTO_ICMPV6,
|
| 352 | csum_partial(na, sizeof(*na) + na_olen, 0));
|
| 353 |
|
| 354 | pip6->payload_len = htons(sizeof(*na) + na_olen);
|
| 355 |
|
| 356 | skb_push(reply, sizeof(struct ipv6hdr));
|
| 357 | skb_push(reply, sizeof(struct ethhdr));
|
| 358 |
|
| 359 | reply->ip_summed = CHECKSUM_UNNECESSARY;
|
| 360 |
|
| 361 | if (p)
|
| 362 | vg = nbp_vlan_group_rcu(p);
|
| 363 | else
|
| 364 | vg = br_vlan_group_rcu(br);
|
| 365 | pvid = br_get_pvid(vg);
|
| 366 | if (pvid == (vlan_tci & VLAN_VID_MASK))
|
| 367 | vlan_tci = 0;
|
| 368 |
|
| 369 | if (vlan_tci)
|
| 370 | __vlan_hwaccel_put_tag(reply, vlan_proto, vlan_tci);
|
| 371 |
|
| 372 | netdev_dbg(dev, "nd send dev %s dst %pI6 dst_hw %pM src %pI6 src_hw %pM\n",
|
| 373 | dev->name, &pip6->daddr, daddr, &pip6->saddr, ha);
|
| 374 |
|
| 375 | if (p) {
|
| 376 | dev_queue_xmit(reply);
|
| 377 | } else {
|
| 378 | skb_reset_mac_header(reply);
|
| 379 | __skb_pull(reply, skb_network_offset(reply));
|
| 380 | reply->ip_summed = CHECKSUM_UNNECESSARY;
|
| 381 | reply->pkt_type = PACKET_HOST;
|
| 382 |
|
| 383 | netif_rx(reply);
|
| 384 | }
|
| 385 | }
|
| 386 |
|
| 387 | static int br_chk_addr_ip6(struct net_device *dev,
|
| 388 | struct netdev_nested_priv *priv)
|
| 389 | {
|
| 390 | struct in6_addr *addr = (struct in6_addr *)priv->data;
|
| 391 |
|
| 392 | if (ipv6_chk_addr(dev_net(dev), addr, dev, 0))
|
| 393 | return 1;
|
| 394 |
|
| 395 | return 0;
|
| 396 | }
|
| 397 |
|
| 398 | static bool br_is_local_ip6(struct net_device *dev, struct in6_addr *addr)
|
| 399 |
|
| 400 | {
|
| 401 | struct netdev_nested_priv priv = {
|
| 402 | .data = (void *)addr,
|
| 403 | };
|
| 404 |
|
| 405 | if (br_chk_addr_ip6(dev, &priv))
|
| 406 | return true;
|
| 407 |
|
| 408 |
|
| 409 | if (netdev_walk_all_upper_dev_rcu(dev, br_chk_addr_ip6, &priv))
|
| 410 | return true;
|
| 411 |
|
| 412 | return false;
|
| 413 | }
|
| 414 |
|
| 415 | void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
|
| 416 | u16 vid, struct net_bridge_port *p, struct nd_msg *msg)
|
| 417 | {
|
| 418 | struct net_device *dev = br->dev;
|
| 419 | struct net_device *vlandev = NULL;
|
| 420 | struct in6_addr *saddr, *daddr;
|
| 421 | struct ipv6hdr *iphdr;
|
| 422 | struct neighbour *n;
|
| 423 |
|
| 424 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = 0;
|
| 425 | BR_INPUT_SKB_CB(skb)->grat_arp = 0;
|
| 426 |
|
| 427 | if (br_is_neigh_suppress_enabled(p, vid))
|
| 428 | return;
|
| 429 |
|
| 430 | if (is_unicast_ether_addr(eth_hdr(skb)->h_dest) &&
|
| 431 | msg->icmph.icmp6_type == NDISC_NEIGHBOUR_SOLICITATION)
|
| 432 | return;
|
| 433 |
|
| 434 | if (msg->icmph.icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT &&
|
| 435 | !msg->icmph.icmp6_solicited) {
|
| 436 |
|
| 437 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
|
| 438 | BR_INPUT_SKB_CB(skb)->grat_arp = 1;
|
| 439 | return;
|
| 440 | }
|
| 441 |
|
| 442 | if (msg->icmph.icmp6_type != NDISC_NEIGHBOUR_SOLICITATION)
|
| 443 | return;
|
| 444 |
|
| 445 | iphdr = ipv6_hdr(skb);
|
| 446 | saddr = &iphdr->saddr;
|
| 447 | daddr = &iphdr->daddr;
|
| 448 |
|
| 449 | if (!ipv6_addr_cmp(saddr, daddr)) {
|
| 450 |
|
| 451 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
|
| 452 | return;
|
| 453 | }
|
| 454 |
|
| 455 | if (vid != 0) {
|
| 456 |
|
| 457 | vlandev = __vlan_find_dev_deep_rcu(br->dev, skb->vlan_proto,
|
| 458 | vid);
|
| 459 | if (!vlandev)
|
| 460 | return;
|
| 461 | } else {
|
| 462 | vlandev = dev;
|
| 463 | }
|
| 464 |
|
| 465 | if (br_is_local_ip6(vlandev, &msg->target)) {
|
| 466 | |
| 467 | * and don't forward to arp suppress ports
|
| 468 |
|
| 469 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
|
| 470 | return;
|
| 471 | }
|
| 472 |
|
| 473 | n = neigh_lookup(&nd_tbl, &msg->target, vlandev);
|
| 474 | if (n) {
|
| 475 | struct net_bridge_fdb_entry *f;
|
| 476 | u8 ha[ETH_ALEN] __aligned(2);
|
| 477 |
|
| 478 | if (!(READ_ONCE(n->nud_state) & NUD_VALID)) {
|
| 479 | neigh_release(n);
|
| 480 | return;
|
| 481 | }
|
| 482 |
|
| 483 | neigh_ha_snapshot(ha, n, n->dev);
|
| 484 | f = br_fdb_find_rcu(br, ha, vid);
|
| 485 | if (f) {
|
| 486 | const struct net_bridge_port *dst = READ_ONCE(f->dst);
|
| 487 | bool replied = false;
|
| 488 |
|
| 489 | if (br_is_neigh_suppress_enabled(dst, vid)) {
|
| 490 | if (vid != 0)
|
| 491 | br_nd_send(br, p, skb, n, ha,
|
| 492 | skb->vlan_proto,
|
| 493 | skb_vlan_tag_get(skb));
|
| 494 | else
|
| 495 | br_nd_send(br, p, skb, n, ha, 0, 0);
|
| 496 | replied = true;
|
| 497 | }
|
| 498 |
|
| 499 | |
| 500 | * mac, indicate to NEIGH_SUPPRESS ports that we
|
| 501 | * have replied
|
| 502 |
|
| 503 | if (replied ||
|
| 504 | br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED))
|
| 505 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
|
| 506 | }
|
| 507 | neigh_release(n);
|
| 508 | }
|
| 509 | }
|
| 510 | #endif
|
| 511 |
|
| 512 | bool br_is_neigh_suppress_enabled(const struct net_bridge_port *p, u16 vid)
|
| 513 | {
|
| 514 | if (!p)
|
| 515 | return false;
|
| 516 |
|
| 517 | if (vid && test_bit(BR_NEIGH_VLAN_SUPPRESS_BIT, &p->flags)) {
|
| 518 | struct net_bridge_vlan_group *vg = nbp_vlan_group_rcu(p);
|
| 519 | struct net_bridge_vlan *v;
|
| 520 |
|
| 521 | v = br_vlan_find(vg, vid);
|
| 522 | if (!v)
|
| 523 | return false;
|
| 524 | return !!(v->priv_flags & BR_VLFLAG_NEIGH_SUPPRESS_ENABLED);
|
| 525 | }
|
| 526 | return test_bit(BR_NEIGH_SUPPRESS_BIT, &p->flags);
|
| 527 | }
|
| 528 |
|
| 529 | bool br_is_neigh_forward_grat_enabled(const struct net_bridge_port *p, u16 vid)
|
| 530 | {
|
| 531 | if (vid && test_bit(BR_NEIGH_VLAN_SUPPRESS_BIT, &p->flags)) {
|
| 532 | struct net_bridge_vlan_group *vg = nbp_vlan_group_rcu(p);
|
| 533 | struct net_bridge_vlan *v;
|
| 534 |
|
| 535 | v = br_vlan_find(vg, vid);
|
| 536 | if (!v)
|
| 537 | return false;
|
| 538 | return !!(v->priv_flags & BR_VLFLAG_NEIGH_FORWARD_GRAT_ENABLED);
|
| 539 | }
|
| 540 | return test_bit(BR_NEIGH_FORWARD_GRAT_BIT, &p->flags);
|
| 541 | }
|