br_fdb.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /*
  2. * Forwarding database
  3. * Linux ethernet bridge
  4. *
  5. * Authors:
  6. * Lennert Buytenhek <buytenh@gnu.org>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/rculist.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/times.h>
  18. #include <linux/netdevice.h>
  19. #include <linux/etherdevice.h>
  20. #include <linux/jhash.h>
  21. #include <linux/random.h>
  22. #include <linux/slab.h>
  23. #include <linux/atomic.h>
  24. #include <asm/unaligned.h>
  25. #include "br_private.h"
  26. static struct kmem_cache *br_fdb_cache __read_mostly;
  27. static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
  28. const unsigned char *addr);
  29. static void fdb_notify(struct net_bridge *br,
  30. const struct net_bridge_fdb_entry *, int);
  31. static u32 fdb_salt __read_mostly;
  32. int __init br_fdb_init(void)
  33. {
  34. br_fdb_cache = kmem_cache_create("bridge_fdb_cache",
  35. sizeof(struct net_bridge_fdb_entry),
  36. 0,
  37. SLAB_HWCACHE_ALIGN, NULL);
  38. if (!br_fdb_cache)
  39. return -ENOMEM;
  40. get_random_bytes(&fdb_salt, sizeof(fdb_salt));
  41. return 0;
  42. }
  43. void br_fdb_fini(void)
  44. {
  45. kmem_cache_destroy(br_fdb_cache);
  46. }
  47. /* if topology_changing then use forward_delay (default 15 sec)
  48. * otherwise keep longer (default 5 minutes)
  49. */
  50. static inline unsigned long hold_time(const struct net_bridge *br)
  51. {
  52. return br->topology_change ? br->forward_delay : br->ageing_time;
  53. }
  54. static inline int has_expired(const struct net_bridge *br,
  55. const struct net_bridge_fdb_entry *fdb)
  56. {
  57. return !fdb->is_static &&
  58. time_before_eq(fdb->updated + hold_time(br), jiffies);
  59. }
  60. static inline int br_mac_hash(const unsigned char *mac)
  61. {
  62. /* use 1 byte of OUI cnd 3 bytes of NIC */
  63. u32 key = get_unaligned((u32 *)(mac + 2));
  64. return jhash_1word(key, fdb_salt) & (BR_HASH_SIZE - 1);
  65. }
  66. static void fdb_rcu_free(struct rcu_head *head)
  67. {
  68. struct net_bridge_fdb_entry *ent
  69. = container_of(head, struct net_bridge_fdb_entry, rcu);
  70. kmem_cache_free(br_fdb_cache, ent);
  71. }
  72. static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f)
  73. {
  74. hlist_del_rcu(&f->hlist);
  75. fdb_notify(br, f, RTM_DELNEIGH);
  76. call_rcu(&f->rcu, fdb_rcu_free);
  77. }
  78. void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr)
  79. {
  80. struct net_bridge *br = p->br;
  81. int i;
  82. spin_lock_bh(&br->hash_lock);
  83. /* Search all chains since old address/hash is unknown */
  84. for (i = 0; i < BR_HASH_SIZE; i++) {
  85. struct hlist_node *h;
  86. hlist_for_each(h, &br->hash[i]) {
  87. struct net_bridge_fdb_entry *f;
  88. f = hlist_entry(h, struct net_bridge_fdb_entry, hlist);
  89. if (f->dst == p && f->is_local) {
  90. /* maybe another port has same hw addr? */
  91. struct net_bridge_port *op;
  92. list_for_each_entry(op, &br->port_list, list) {
  93. if (op != p &&
  94. ether_addr_equal(op->dev->dev_addr,
  95. f->addr.addr)) {
  96. f->dst = op;
  97. goto insert;
  98. }
  99. }
  100. /* delete old one */
  101. fdb_delete(br, f);
  102. goto insert;
  103. }
  104. }
  105. }
  106. insert:
  107. /* insert new address, may fail if invalid address or dup. */
  108. fdb_insert(br, p, newaddr);
  109. spin_unlock_bh(&br->hash_lock);
  110. }
  111. void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr)
  112. {
  113. struct net_bridge_fdb_entry *f;
  114. /* If old entry was unassociated with any port, then delete it. */
  115. f = __br_fdb_get(br, br->dev->dev_addr);
  116. if (f && f->is_local && !f->dst)
  117. fdb_delete(br, f);
  118. fdb_insert(br, NULL, newaddr);
  119. }
  120. void br_fdb_cleanup(unsigned long _data)
  121. {
  122. struct net_bridge *br = (struct net_bridge *)_data;
  123. unsigned long delay = hold_time(br);
  124. unsigned long next_timer = jiffies + br->ageing_time;
  125. int i;
  126. spin_lock(&br->hash_lock);
  127. for (i = 0; i < BR_HASH_SIZE; i++) {
  128. struct net_bridge_fdb_entry *f;
  129. struct hlist_node *h, *n;
  130. hlist_for_each_entry_safe(f, h, n, &br->hash[i], hlist) {
  131. unsigned long this_timer;
  132. if (f->is_static)
  133. continue;
  134. this_timer = f->updated + delay;
  135. if (time_before_eq(this_timer, jiffies))
  136. fdb_delete(br, f);
  137. else if (time_before(this_timer, next_timer))
  138. next_timer = this_timer;
  139. }
  140. }
  141. spin_unlock(&br->hash_lock);
  142. mod_timer(&br->gc_timer, round_jiffies_up(next_timer));
  143. }
  144. /* Completely flush all dynamic entries in forwarding database.*/
  145. void br_fdb_flush(struct net_bridge *br)
  146. {
  147. int i;
  148. spin_lock_bh(&br->hash_lock);
  149. for (i = 0; i < BR_HASH_SIZE; i++) {
  150. struct net_bridge_fdb_entry *f;
  151. struct hlist_node *h, *n;
  152. hlist_for_each_entry_safe(f, h, n, &br->hash[i], hlist) {
  153. if (!f->is_static)
  154. fdb_delete(br, f);
  155. }
  156. }
  157. spin_unlock_bh(&br->hash_lock);
  158. }
  159. /* Flush all entries referring to a specific port.
  160. * if do_all is set also flush static entries
  161. */
  162. void br_fdb_delete_by_port(struct net_bridge *br,
  163. const struct net_bridge_port *p,
  164. int do_all)
  165. {
  166. int i;
  167. spin_lock_bh(&br->hash_lock);
  168. for (i = 0; i < BR_HASH_SIZE; i++) {
  169. struct hlist_node *h, *g;
  170. hlist_for_each_safe(h, g, &br->hash[i]) {
  171. struct net_bridge_fdb_entry *f
  172. = hlist_entry(h, struct net_bridge_fdb_entry, hlist);
  173. if (f->dst != p)
  174. continue;
  175. if (f->is_static && !do_all)
  176. continue;
  177. /*
  178. * if multiple ports all have the same device address
  179. * then when one port is deleted, assign
  180. * the local entry to other port
  181. */
  182. if (f->is_local) {
  183. struct net_bridge_port *op;
  184. list_for_each_entry(op, &br->port_list, list) {
  185. if (op != p &&
  186. ether_addr_equal(op->dev->dev_addr,
  187. f->addr.addr)) {
  188. f->dst = op;
  189. goto skip_delete;
  190. }
  191. }
  192. }
  193. fdb_delete(br, f);
  194. skip_delete: ;
  195. }
  196. }
  197. spin_unlock_bh(&br->hash_lock);
  198. }
  199. /* No locking or refcounting, assumes caller has rcu_read_lock */
  200. struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
  201. const unsigned char *addr)
  202. {
  203. struct hlist_node *h;
  204. struct net_bridge_fdb_entry *fdb;
  205. hlist_for_each_entry_rcu(fdb, h, &br->hash[br_mac_hash(addr)], hlist) {
  206. if (ether_addr_equal(fdb->addr.addr, addr)) {
  207. if (unlikely(has_expired(br, fdb)))
  208. break;
  209. return fdb;
  210. }
  211. }
  212. return NULL;
  213. }
  214. #if IS_ENABLED(CONFIG_ATM_LANE)
  215. /* Interface used by ATM LANE hook to test
  216. * if an addr is on some other bridge port */
  217. int br_fdb_test_addr(struct net_device *dev, unsigned char *addr)
  218. {
  219. struct net_bridge_fdb_entry *fdb;
  220. struct net_bridge_port *port;
  221. int ret;
  222. rcu_read_lock();
  223. port = br_port_get_rcu(dev);
  224. if (!port)
  225. ret = 0;
  226. else {
  227. fdb = __br_fdb_get(port->br, addr);
  228. ret = fdb && fdb->dst && fdb->dst->dev != dev &&
  229. fdb->dst->state == BR_STATE_FORWARDING;
  230. }
  231. rcu_read_unlock();
  232. return ret;
  233. }
  234. #endif /* CONFIG_ATM_LANE */
  235. /*
  236. * Fill buffer with forwarding table records in
  237. * the API format.
  238. */
  239. int br_fdb_fillbuf(struct net_bridge *br, void *buf,
  240. unsigned long maxnum, unsigned long skip)
  241. {
  242. struct __fdb_entry *fe = buf;
  243. int i, num = 0;
  244. struct hlist_node *h;
  245. struct net_bridge_fdb_entry *f;
  246. memset(buf, 0, maxnum*sizeof(struct __fdb_entry));
  247. rcu_read_lock();
  248. for (i = 0; i < BR_HASH_SIZE; i++) {
  249. hlist_for_each_entry_rcu(f, h, &br->hash[i], hlist) {
  250. if (num >= maxnum)
  251. goto out;
  252. if (has_expired(br, f))
  253. continue;
  254. /* ignore pseudo entry for local MAC address */
  255. if (!f->dst)
  256. continue;
  257. if (skip) {
  258. --skip;
  259. continue;
  260. }
  261. /* convert from internal format to API */
  262. memcpy(fe->mac_addr, f->addr.addr, ETH_ALEN);
  263. /* due to ABI compat need to split into hi/lo */
  264. fe->port_no = f->dst->port_no;
  265. fe->port_hi = f->dst->port_no >> 8;
  266. fe->is_local = f->is_local;
  267. if (!f->is_static)
  268. fe->ageing_timer_value = jiffies_delta_to_clock_t(jiffies - f->updated);
  269. ++fe;
  270. ++num;
  271. }
  272. }
  273. out:
  274. rcu_read_unlock();
  275. return num;
  276. }
  277. static struct net_bridge_fdb_entry *fdb_find(struct hlist_head *head,
  278. const unsigned char *addr)
  279. {
  280. struct hlist_node *h;
  281. struct net_bridge_fdb_entry *fdb;
  282. hlist_for_each_entry(fdb, h, head, hlist) {
  283. if (ether_addr_equal(fdb->addr.addr, addr))
  284. return fdb;
  285. }
  286. return NULL;
  287. }
  288. static struct net_bridge_fdb_entry *fdb_find_rcu(struct hlist_head *head,
  289. const unsigned char *addr)
  290. {
  291. struct hlist_node *h;
  292. struct net_bridge_fdb_entry *fdb;
  293. hlist_for_each_entry_rcu(fdb, h, head, hlist) {
  294. if (ether_addr_equal(fdb->addr.addr, addr))
  295. return fdb;
  296. }
  297. return NULL;
  298. }
  299. static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head,
  300. struct net_bridge_port *source,
  301. const unsigned char *addr)
  302. {
  303. struct net_bridge_fdb_entry *fdb;
  304. fdb = kmem_cache_alloc(br_fdb_cache, GFP_ATOMIC);
  305. if (fdb) {
  306. memcpy(fdb->addr.addr, addr, ETH_ALEN);
  307. fdb->dst = source;
  308. fdb->is_local = 0;
  309. fdb->is_static = 0;
  310. fdb->updated = fdb->used = jiffies;
  311. hlist_add_head_rcu(&fdb->hlist, head);
  312. }
  313. return fdb;
  314. }
  315. static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
  316. const unsigned char *addr)
  317. {
  318. struct hlist_head *head = &br->hash[br_mac_hash(addr)];
  319. struct net_bridge_fdb_entry *fdb;
  320. if (!is_valid_ether_addr(addr))
  321. return -EINVAL;
  322. fdb = fdb_find(head, addr);
  323. if (fdb) {
  324. /* it is okay to have multiple ports with same
  325. * address, just use the first one.
  326. */
  327. if (fdb->is_local)
  328. return 0;
  329. br_warn(br, "adding interface %s with same address "
  330. "as a received packet\n",
  331. source->dev->name);
  332. fdb_delete(br, fdb);
  333. }
  334. fdb = fdb_create(head, source, addr);
  335. if (!fdb)
  336. return -ENOMEM;
  337. fdb->is_local = fdb->is_static = 1;
  338. fdb_notify(br, fdb, RTM_NEWNEIGH);
  339. return 0;
  340. }
  341. /* Add entry for local address of interface */
  342. int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
  343. const unsigned char *addr)
  344. {
  345. int ret;
  346. spin_lock_bh(&br->hash_lock);
  347. ret = fdb_insert(br, source, addr);
  348. spin_unlock_bh(&br->hash_lock);
  349. return ret;
  350. }
  351. void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
  352. const unsigned char *addr)
  353. {
  354. struct hlist_head *head = &br->hash[br_mac_hash(addr)];
  355. struct net_bridge_fdb_entry *fdb;
  356. /* some users want to always flood. */
  357. if (hold_time(br) == 0)
  358. return;
  359. /* ignore packets unless we are using this port */
  360. if (!(source->state == BR_STATE_LEARNING ||
  361. source->state == BR_STATE_FORWARDING))
  362. return;
  363. fdb = fdb_find_rcu(head, addr);
  364. if (likely(fdb)) {
  365. /* attempt to update an entry for a local interface */
  366. if (unlikely(fdb->is_local)) {
  367. if (net_ratelimit())
  368. br_warn(br, "received packet on %s with "
  369. "own address as source address\n",
  370. source->dev->name);
  371. } else {
  372. /* fastpath: update of existing entry */
  373. fdb->dst = source;
  374. fdb->updated = jiffies;
  375. }
  376. } else {
  377. spin_lock(&br->hash_lock);
  378. if (likely(!fdb_find(head, addr))) {
  379. fdb = fdb_create(head, source, addr);
  380. if (fdb)
  381. fdb_notify(br, fdb, RTM_NEWNEIGH);
  382. }
  383. /* else we lose race and someone else inserts
  384. * it first, don't bother updating
  385. */
  386. spin_unlock(&br->hash_lock);
  387. }
  388. }
  389. static int fdb_to_nud(const struct net_bridge_fdb_entry *fdb)
  390. {
  391. if (fdb->is_local)
  392. return NUD_PERMANENT;
  393. else if (fdb->is_static)
  394. return NUD_NOARP;
  395. else if (has_expired(fdb->dst->br, fdb))
  396. return NUD_STALE;
  397. else
  398. return NUD_REACHABLE;
  399. }
  400. static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br,
  401. const struct net_bridge_fdb_entry *fdb,
  402. u32 pid, u32 seq, int type, unsigned int flags)
  403. {
  404. unsigned long now = jiffies;
  405. struct nda_cacheinfo ci;
  406. struct nlmsghdr *nlh;
  407. struct ndmsg *ndm;
  408. nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndm), flags);
  409. if (nlh == NULL)
  410. return -EMSGSIZE;
  411. ndm = nlmsg_data(nlh);
  412. ndm->ndm_family = AF_BRIDGE;
  413. ndm->ndm_pad1 = 0;
  414. ndm->ndm_pad2 = 0;
  415. ndm->ndm_flags = 0;
  416. ndm->ndm_type = 0;
  417. ndm->ndm_ifindex = fdb->dst ? fdb->dst->dev->ifindex : br->dev->ifindex;
  418. ndm->ndm_state = fdb_to_nud(fdb);
  419. if (nla_put(skb, NDA_LLADDR, ETH_ALEN, &fdb->addr))
  420. goto nla_put_failure;
  421. ci.ndm_used = jiffies_to_clock_t(now - fdb->used);
  422. ci.ndm_confirmed = 0;
  423. ci.ndm_updated = jiffies_to_clock_t(now - fdb->updated);
  424. ci.ndm_refcnt = 0;
  425. if (nla_put(skb, NDA_CACHEINFO, sizeof(ci), &ci))
  426. goto nla_put_failure;
  427. return nlmsg_end(skb, nlh);
  428. nla_put_failure:
  429. nlmsg_cancel(skb, nlh);
  430. return -EMSGSIZE;
  431. }
  432. static inline size_t fdb_nlmsg_size(void)
  433. {
  434. return NLMSG_ALIGN(sizeof(struct ndmsg))
  435. + nla_total_size(ETH_ALEN) /* NDA_LLADDR */
  436. + nla_total_size(sizeof(struct nda_cacheinfo));
  437. }
  438. static void fdb_notify(struct net_bridge *br,
  439. const struct net_bridge_fdb_entry *fdb, int type)
  440. {
  441. struct net *net = dev_net(br->dev);
  442. struct sk_buff *skb;
  443. int err = -ENOBUFS;
  444. skb = nlmsg_new(fdb_nlmsg_size(), GFP_ATOMIC);
  445. if (skb == NULL)
  446. goto errout;
  447. err = fdb_fill_info(skb, br, fdb, 0, 0, type, 0);
  448. if (err < 0) {
  449. /* -EMSGSIZE implies BUG in fdb_nlmsg_size() */
  450. WARN_ON(err == -EMSGSIZE);
  451. kfree_skb(skb);
  452. goto errout;
  453. }
  454. rtnl_notify(skb, net, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
  455. return;
  456. errout:
  457. if (err < 0)
  458. rtnl_set_sk_err(net, RTNLGRP_NEIGH, err);
  459. }
  460. /* Dump information about entries, in response to GETNEIGH */
  461. int br_fdb_dump(struct sk_buff *skb,
  462. struct netlink_callback *cb,
  463. struct net_device *dev,
  464. int idx)
  465. {
  466. struct net_bridge *br = netdev_priv(dev);
  467. int i;
  468. if (!(dev->priv_flags & IFF_EBRIDGE))
  469. goto out;
  470. for (i = 0; i < BR_HASH_SIZE; i++) {
  471. struct hlist_node *h;
  472. struct net_bridge_fdb_entry *f;
  473. hlist_for_each_entry_rcu(f, h, &br->hash[i], hlist) {
  474. if (idx < cb->args[0])
  475. goto skip;
  476. if (fdb_fill_info(skb, br, f,
  477. NETLINK_CB(cb->skb).pid,
  478. cb->nlh->nlmsg_seq,
  479. RTM_NEWNEIGH,
  480. NLM_F_MULTI) < 0)
  481. break;
  482. skip:
  483. ++idx;
  484. }
  485. }
  486. out:
  487. return idx;
  488. }
  489. /* Update (create or replace) forwarding database entry */
  490. static int fdb_add_entry(struct net_bridge_port *source, const __u8 *addr,
  491. __u16 state, __u16 flags)
  492. {
  493. struct net_bridge *br = source->br;
  494. struct hlist_head *head = &br->hash[br_mac_hash(addr)];
  495. struct net_bridge_fdb_entry *fdb;
  496. fdb = fdb_find(head, addr);
  497. if (fdb == NULL) {
  498. if (!(flags & NLM_F_CREATE))
  499. return -ENOENT;
  500. fdb = fdb_create(head, source, addr);
  501. if (!fdb)
  502. return -ENOMEM;
  503. fdb_notify(br, fdb, RTM_NEWNEIGH);
  504. } else {
  505. if (flags & NLM_F_EXCL)
  506. return -EEXIST;
  507. }
  508. if (fdb_to_nud(fdb) != state) {
  509. if (state & NUD_PERMANENT)
  510. fdb->is_local = fdb->is_static = 1;
  511. else if (state & NUD_NOARP) {
  512. fdb->is_local = 0;
  513. fdb->is_static = 1;
  514. } else
  515. fdb->is_local = fdb->is_static = 0;
  516. fdb->updated = fdb->used = jiffies;
  517. fdb_notify(br, fdb, RTM_NEWNEIGH);
  518. }
  519. return 0;
  520. }
  521. /* Add new permanent fdb entry with RTM_NEWNEIGH */
  522. int br_fdb_add(struct ndmsg *ndm, struct net_device *dev,
  523. unsigned char *addr, u16 nlh_flags)
  524. {
  525. struct net_bridge_port *p;
  526. int err = 0;
  527. if (!(ndm->ndm_state & (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE))) {
  528. pr_info("bridge: RTM_NEWNEIGH with invalid state %#x\n", ndm->ndm_state);
  529. return -EINVAL;
  530. }
  531. p = br_port_get_rtnl(dev);
  532. if (p == NULL) {
  533. pr_info("bridge: RTM_NEWNEIGH %s not a bridge port\n",
  534. dev->name);
  535. return -EINVAL;
  536. }
  537. if (ndm->ndm_flags & NTF_USE) {
  538. rcu_read_lock();
  539. br_fdb_update(p->br, p, addr);
  540. rcu_read_unlock();
  541. } else {
  542. spin_lock_bh(&p->br->hash_lock);
  543. err = fdb_add_entry(p, addr, ndm->ndm_state, nlh_flags);
  544. spin_unlock_bh(&p->br->hash_lock);
  545. }
  546. return err;
  547. }
  548. static int fdb_delete_by_addr(struct net_bridge_port *p, u8 *addr)
  549. {
  550. struct net_bridge *br = p->br;
  551. struct hlist_head *head = &br->hash[br_mac_hash(addr)];
  552. struct net_bridge_fdb_entry *fdb;
  553. fdb = fdb_find(head, addr);
  554. if (!fdb)
  555. return -ENOENT;
  556. fdb_delete(p->br, fdb);
  557. return 0;
  558. }
  559. /* Remove neighbor entry with RTM_DELNEIGH */
  560. int br_fdb_delete(struct ndmsg *ndm, struct net_device *dev,
  561. unsigned char *addr)
  562. {
  563. struct net_bridge_port *p;
  564. int err;
  565. p = br_port_get_rtnl(dev);
  566. if (p == NULL) {
  567. pr_info("bridge: RTM_DELNEIGH %s not a bridge port\n",
  568. dev->name);
  569. return -EINVAL;
  570. }
  571. spin_lock_bh(&p->br->hash_lock);
  572. err = fdb_delete_by_addr(p, addr);
  573. spin_unlock_bh(&p->br->hash_lock);
  574. return err;
  575. }