hard-interface.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. /*
  2. * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:
  3. *
  4. * Marek Lindner, Simon Wunderlich
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of version 2 of the GNU General Public
  8. * License as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA
  19. *
  20. */
  21. #include "main.h"
  22. #include "hard-interface.h"
  23. #include "soft-interface.h"
  24. #include "send.h"
  25. #include "translation-table.h"
  26. #include "routing.h"
  27. #include "bat_sysfs.h"
  28. #include "originator.h"
  29. #include "hash.h"
  30. #include <linux/if_arp.h>
  31. static int batman_skb_recv(struct sk_buff *skb,
  32. struct net_device *dev,
  33. struct packet_type *ptype,
  34. struct net_device *orig_dev);
  35. void hardif_free_rcu(struct rcu_head *rcu)
  36. {
  37. struct hard_iface *hard_iface;
  38. hard_iface = container_of(rcu, struct hard_iface, rcu);
  39. dev_put(hard_iface->net_dev);
  40. kfree(hard_iface);
  41. }
  42. struct hard_iface *hardif_get_by_netdev(struct net_device *net_dev)
  43. {
  44. struct hard_iface *hard_iface;
  45. rcu_read_lock();
  46. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  47. if (hard_iface->net_dev == net_dev &&
  48. atomic_inc_not_zero(&hard_iface->refcount))
  49. goto out;
  50. }
  51. hard_iface = NULL;
  52. out:
  53. rcu_read_unlock();
  54. return hard_iface;
  55. }
  56. static int is_valid_iface(struct net_device *net_dev)
  57. {
  58. if (net_dev->flags & IFF_LOOPBACK)
  59. return 0;
  60. if (net_dev->type != ARPHRD_ETHER)
  61. return 0;
  62. if (net_dev->addr_len != ETH_ALEN)
  63. return 0;
  64. /* no batman over batman */
  65. if (softif_is_valid(net_dev))
  66. return 0;
  67. /* Device is being bridged */
  68. /* if (net_dev->priv_flags & IFF_BRIDGE_PORT)
  69. return 0; */
  70. return 1;
  71. }
  72. static struct hard_iface *hardif_get_active(struct net_device *soft_iface)
  73. {
  74. struct hard_iface *hard_iface;
  75. rcu_read_lock();
  76. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  77. if (hard_iface->soft_iface != soft_iface)
  78. continue;
  79. if (hard_iface->if_status == IF_ACTIVE &&
  80. atomic_inc_not_zero(&hard_iface->refcount))
  81. goto out;
  82. }
  83. hard_iface = NULL;
  84. out:
  85. rcu_read_unlock();
  86. return hard_iface;
  87. }
  88. static void primary_if_update_addr(struct bat_priv *bat_priv)
  89. {
  90. struct vis_packet *vis_packet;
  91. struct hard_iface *primary_if;
  92. primary_if = primary_if_get_selected(bat_priv);
  93. if (!primary_if)
  94. goto out;
  95. vis_packet = (struct vis_packet *)
  96. bat_priv->my_vis_info->skb_packet->data;
  97. memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN);
  98. memcpy(vis_packet->sender_orig,
  99. primary_if->net_dev->dev_addr, ETH_ALEN);
  100. out:
  101. if (primary_if)
  102. hardif_free_ref(primary_if);
  103. }
  104. static void primary_if_select(struct bat_priv *bat_priv,
  105. struct hard_iface *new_hard_iface)
  106. {
  107. struct hard_iface *curr_hard_iface;
  108. struct batman_packet *batman_packet;
  109. ASSERT_RTNL();
  110. if (new_hard_iface && !atomic_inc_not_zero(&new_hard_iface->refcount))
  111. new_hard_iface = NULL;
  112. curr_hard_iface = bat_priv->primary_if;
  113. rcu_assign_pointer(bat_priv->primary_if, new_hard_iface);
  114. if (curr_hard_iface)
  115. hardif_free_ref(curr_hard_iface);
  116. if (!new_hard_iface)
  117. return;
  118. batman_packet = (struct batman_packet *)(new_hard_iface->packet_buff);
  119. batman_packet->flags = PRIMARIES_FIRST_HOP;
  120. batman_packet->ttl = TTL;
  121. primary_if_update_addr(bat_priv);
  122. /***
  123. * hacky trick to make sure that we send the TT information via
  124. * our new primary interface
  125. */
  126. atomic_set(&bat_priv->tt_local_changed, 1);
  127. }
  128. static bool hardif_is_iface_up(struct hard_iface *hard_iface)
  129. {
  130. if (hard_iface->net_dev->flags & IFF_UP)
  131. return true;
  132. return false;
  133. }
  134. static void update_mac_addresses(struct hard_iface *hard_iface)
  135. {
  136. memcpy(((struct batman_packet *)(hard_iface->packet_buff))->orig,
  137. hard_iface->net_dev->dev_addr, ETH_ALEN);
  138. memcpy(((struct batman_packet *)(hard_iface->packet_buff))->prev_sender,
  139. hard_iface->net_dev->dev_addr, ETH_ALEN);
  140. }
  141. static void check_known_mac_addr(struct net_device *net_dev)
  142. {
  143. struct hard_iface *hard_iface;
  144. rcu_read_lock();
  145. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  146. if ((hard_iface->if_status != IF_ACTIVE) &&
  147. (hard_iface->if_status != IF_TO_BE_ACTIVATED))
  148. continue;
  149. if (hard_iface->net_dev == net_dev)
  150. continue;
  151. if (!compare_eth(hard_iface->net_dev->dev_addr,
  152. net_dev->dev_addr))
  153. continue;
  154. pr_warning("The newly added mac address (%pM) already exists "
  155. "on: %s\n", net_dev->dev_addr,
  156. hard_iface->net_dev->name);
  157. pr_warning("It is strongly recommended to keep mac addresses "
  158. "unique to avoid problems!\n");
  159. }
  160. rcu_read_unlock();
  161. }
  162. int hardif_min_mtu(struct net_device *soft_iface)
  163. {
  164. struct bat_priv *bat_priv = netdev_priv(soft_iface);
  165. struct hard_iface *hard_iface;
  166. /* allow big frames if all devices are capable to do so
  167. * (have MTU > 1500 + BAT_HEADER_LEN) */
  168. int min_mtu = ETH_DATA_LEN;
  169. if (atomic_read(&bat_priv->fragmentation))
  170. goto out;
  171. rcu_read_lock();
  172. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  173. if ((hard_iface->if_status != IF_ACTIVE) &&
  174. (hard_iface->if_status != IF_TO_BE_ACTIVATED))
  175. continue;
  176. if (hard_iface->soft_iface != soft_iface)
  177. continue;
  178. min_mtu = min_t(int, hard_iface->net_dev->mtu - BAT_HEADER_LEN,
  179. min_mtu);
  180. }
  181. rcu_read_unlock();
  182. out:
  183. return min_mtu;
  184. }
  185. /* adjusts the MTU if a new interface with a smaller MTU appeared. */
  186. void update_min_mtu(struct net_device *soft_iface)
  187. {
  188. int min_mtu;
  189. min_mtu = hardif_min_mtu(soft_iface);
  190. if (soft_iface->mtu != min_mtu)
  191. soft_iface->mtu = min_mtu;
  192. }
  193. static void hardif_activate_interface(struct hard_iface *hard_iface)
  194. {
  195. struct bat_priv *bat_priv;
  196. struct hard_iface *primary_if = NULL;
  197. if (hard_iface->if_status != IF_INACTIVE)
  198. goto out;
  199. bat_priv = netdev_priv(hard_iface->soft_iface);
  200. update_mac_addresses(hard_iface);
  201. hard_iface->if_status = IF_TO_BE_ACTIVATED;
  202. /**
  203. * the first active interface becomes our primary interface or
  204. * the next active interface after the old primay interface was removed
  205. */
  206. primary_if = primary_if_get_selected(bat_priv);
  207. if (!primary_if)
  208. primary_if_select(bat_priv, hard_iface);
  209. bat_info(hard_iface->soft_iface, "Interface activated: %s\n",
  210. hard_iface->net_dev->name);
  211. update_min_mtu(hard_iface->soft_iface);
  212. out:
  213. if (primary_if)
  214. hardif_free_ref(primary_if);
  215. }
  216. static void hardif_deactivate_interface(struct hard_iface *hard_iface)
  217. {
  218. if ((hard_iface->if_status != IF_ACTIVE) &&
  219. (hard_iface->if_status != IF_TO_BE_ACTIVATED))
  220. return;
  221. hard_iface->if_status = IF_INACTIVE;
  222. bat_info(hard_iface->soft_iface, "Interface deactivated: %s\n",
  223. hard_iface->net_dev->name);
  224. update_min_mtu(hard_iface->soft_iface);
  225. }
  226. int hardif_enable_interface(struct hard_iface *hard_iface, char *iface_name)
  227. {
  228. struct bat_priv *bat_priv;
  229. struct batman_packet *batman_packet;
  230. struct net_device *soft_iface;
  231. int ret;
  232. if (hard_iface->if_status != IF_NOT_IN_USE)
  233. goto out;
  234. if (!atomic_inc_not_zero(&hard_iface->refcount))
  235. goto out;
  236. soft_iface = dev_get_by_name(&init_net, iface_name);
  237. if (!soft_iface) {
  238. soft_iface = softif_create(iface_name);
  239. if (!soft_iface) {
  240. ret = -ENOMEM;
  241. goto err;
  242. }
  243. /* dev_get_by_name() increases the reference counter for us */
  244. dev_hold(soft_iface);
  245. }
  246. if (!softif_is_valid(soft_iface)) {
  247. pr_err("Can't create batman mesh interface %s: "
  248. "already exists as regular interface\n",
  249. soft_iface->name);
  250. dev_put(soft_iface);
  251. ret = -EINVAL;
  252. goto err;
  253. }
  254. hard_iface->soft_iface = soft_iface;
  255. bat_priv = netdev_priv(hard_iface->soft_iface);
  256. hard_iface->packet_len = BAT_PACKET_LEN;
  257. hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);
  258. if (!hard_iface->packet_buff) {
  259. bat_err(hard_iface->soft_iface, "Can't add interface packet "
  260. "(%s): out of memory\n", hard_iface->net_dev->name);
  261. ret = -ENOMEM;
  262. goto err;
  263. }
  264. batman_packet = (struct batman_packet *)(hard_iface->packet_buff);
  265. batman_packet->packet_type = BAT_PACKET;
  266. batman_packet->version = COMPAT_VERSION;
  267. batman_packet->flags = 0;
  268. batman_packet->ttl = 2;
  269. batman_packet->tq = TQ_MAX_VALUE;
  270. batman_packet->num_tt = 0;
  271. hard_iface->if_num = bat_priv->num_ifaces;
  272. bat_priv->num_ifaces++;
  273. hard_iface->if_status = IF_INACTIVE;
  274. orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
  275. hard_iface->batman_adv_ptype.type = __constant_htons(ETH_P_BATMAN);
  276. hard_iface->batman_adv_ptype.func = batman_skb_recv;
  277. hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
  278. dev_add_pack(&hard_iface->batman_adv_ptype);
  279. atomic_set(&hard_iface->seqno, 1);
  280. atomic_set(&hard_iface->frag_seqno, 1);
  281. bat_info(hard_iface->soft_iface, "Adding interface: %s\n",
  282. hard_iface->net_dev->name);
  283. if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
  284. ETH_DATA_LEN + BAT_HEADER_LEN)
  285. bat_info(hard_iface->soft_iface,
  286. "The MTU of interface %s is too small (%i) to handle "
  287. "the transport of batman-adv packets. Packets going "
  288. "over this interface will be fragmented on layer2 "
  289. "which could impact the performance. Setting the MTU "
  290. "to %zi would solve the problem.\n",
  291. hard_iface->net_dev->name, hard_iface->net_dev->mtu,
  292. ETH_DATA_LEN + BAT_HEADER_LEN);
  293. if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
  294. ETH_DATA_LEN + BAT_HEADER_LEN)
  295. bat_info(hard_iface->soft_iface,
  296. "The MTU of interface %s is too small (%i) to handle "
  297. "the transport of batman-adv packets. If you experience"
  298. " problems getting traffic through try increasing the "
  299. "MTU to %zi.\n",
  300. hard_iface->net_dev->name, hard_iface->net_dev->mtu,
  301. ETH_DATA_LEN + BAT_HEADER_LEN);
  302. if (hardif_is_iface_up(hard_iface))
  303. hardif_activate_interface(hard_iface);
  304. else
  305. bat_err(hard_iface->soft_iface, "Not using interface %s "
  306. "(retrying later): interface not active\n",
  307. hard_iface->net_dev->name);
  308. /* begin scheduling originator messages on that interface */
  309. schedule_own_packet(hard_iface);
  310. out:
  311. return 0;
  312. err:
  313. hardif_free_ref(hard_iface);
  314. return ret;
  315. }
  316. void hardif_disable_interface(struct hard_iface *hard_iface)
  317. {
  318. struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
  319. struct hard_iface *primary_if = NULL;
  320. if (hard_iface->if_status == IF_ACTIVE)
  321. hardif_deactivate_interface(hard_iface);
  322. if (hard_iface->if_status != IF_INACTIVE)
  323. goto out;
  324. bat_info(hard_iface->soft_iface, "Removing interface: %s\n",
  325. hard_iface->net_dev->name);
  326. dev_remove_pack(&hard_iface->batman_adv_ptype);
  327. bat_priv->num_ifaces--;
  328. orig_hash_del_if(hard_iface, bat_priv->num_ifaces);
  329. primary_if = primary_if_get_selected(bat_priv);
  330. if (hard_iface == primary_if) {
  331. struct hard_iface *new_if;
  332. new_if = hardif_get_active(hard_iface->soft_iface);
  333. primary_if_select(bat_priv, new_if);
  334. if (new_if)
  335. hardif_free_ref(new_if);
  336. }
  337. kfree(hard_iface->packet_buff);
  338. hard_iface->packet_buff = NULL;
  339. hard_iface->if_status = IF_NOT_IN_USE;
  340. /* delete all references to this hard_iface */
  341. purge_orig_ref(bat_priv);
  342. purge_outstanding_packets(bat_priv, hard_iface);
  343. dev_put(hard_iface->soft_iface);
  344. /* nobody uses this interface anymore */
  345. if (!bat_priv->num_ifaces)
  346. softif_destroy(hard_iface->soft_iface);
  347. hard_iface->soft_iface = NULL;
  348. hardif_free_ref(hard_iface);
  349. out:
  350. if (primary_if)
  351. hardif_free_ref(primary_if);
  352. }
  353. static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
  354. {
  355. struct hard_iface *hard_iface;
  356. int ret;
  357. ASSERT_RTNL();
  358. ret = is_valid_iface(net_dev);
  359. if (ret != 1)
  360. goto out;
  361. dev_hold(net_dev);
  362. hard_iface = kmalloc(sizeof(struct hard_iface), GFP_ATOMIC);
  363. if (!hard_iface) {
  364. pr_err("Can't add interface (%s): out of memory\n",
  365. net_dev->name);
  366. goto release_dev;
  367. }
  368. ret = sysfs_add_hardif(&hard_iface->hardif_obj, net_dev);
  369. if (ret)
  370. goto free_if;
  371. hard_iface->if_num = -1;
  372. hard_iface->net_dev = net_dev;
  373. hard_iface->soft_iface = NULL;
  374. hard_iface->if_status = IF_NOT_IN_USE;
  375. INIT_LIST_HEAD(&hard_iface->list);
  376. /* extra reference for return */
  377. atomic_set(&hard_iface->refcount, 2);
  378. check_known_mac_addr(hard_iface->net_dev);
  379. list_add_tail_rcu(&hard_iface->list, &hardif_list);
  380. return hard_iface;
  381. free_if:
  382. kfree(hard_iface);
  383. release_dev:
  384. dev_put(net_dev);
  385. out:
  386. return NULL;
  387. }
  388. static void hardif_remove_interface(struct hard_iface *hard_iface)
  389. {
  390. ASSERT_RTNL();
  391. /* first deactivate interface */
  392. if (hard_iface->if_status != IF_NOT_IN_USE)
  393. hardif_disable_interface(hard_iface);
  394. if (hard_iface->if_status != IF_NOT_IN_USE)
  395. return;
  396. hard_iface->if_status = IF_TO_BE_REMOVED;
  397. sysfs_del_hardif(&hard_iface->hardif_obj);
  398. hardif_free_ref(hard_iface);
  399. }
  400. void hardif_remove_interfaces(void)
  401. {
  402. struct hard_iface *hard_iface, *hard_iface_tmp;
  403. rtnl_lock();
  404. list_for_each_entry_safe(hard_iface, hard_iface_tmp,
  405. &hardif_list, list) {
  406. list_del_rcu(&hard_iface->list);
  407. hardif_remove_interface(hard_iface);
  408. }
  409. rtnl_unlock();
  410. }
  411. static int hard_if_event(struct notifier_block *this,
  412. unsigned long event, void *ptr)
  413. {
  414. struct net_device *net_dev = (struct net_device *)ptr;
  415. struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev);
  416. struct hard_iface *primary_if = NULL;
  417. struct bat_priv *bat_priv;
  418. if (!hard_iface && event == NETDEV_REGISTER)
  419. hard_iface = hardif_add_interface(net_dev);
  420. if (!hard_iface)
  421. goto out;
  422. switch (event) {
  423. case NETDEV_UP:
  424. hardif_activate_interface(hard_iface);
  425. break;
  426. case NETDEV_GOING_DOWN:
  427. case NETDEV_DOWN:
  428. hardif_deactivate_interface(hard_iface);
  429. break;
  430. case NETDEV_UNREGISTER:
  431. list_del_rcu(&hard_iface->list);
  432. hardif_remove_interface(hard_iface);
  433. break;
  434. case NETDEV_CHANGEMTU:
  435. if (hard_iface->soft_iface)
  436. update_min_mtu(hard_iface->soft_iface);
  437. break;
  438. case NETDEV_CHANGEADDR:
  439. if (hard_iface->if_status == IF_NOT_IN_USE)
  440. goto hardif_put;
  441. check_known_mac_addr(hard_iface->net_dev);
  442. update_mac_addresses(hard_iface);
  443. bat_priv = netdev_priv(hard_iface->soft_iface);
  444. primary_if = primary_if_get_selected(bat_priv);
  445. if (!primary_if)
  446. goto hardif_put;
  447. if (hard_iface == primary_if)
  448. primary_if_update_addr(bat_priv);
  449. break;
  450. default:
  451. break;
  452. };
  453. hardif_put:
  454. hardif_free_ref(hard_iface);
  455. out:
  456. if (primary_if)
  457. hardif_free_ref(primary_if);
  458. return NOTIFY_DONE;
  459. }
  460. /* receive a packet with the batman ethertype coming on a hard
  461. * interface */
  462. static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
  463. struct packet_type *ptype,
  464. struct net_device *orig_dev)
  465. {
  466. struct bat_priv *bat_priv;
  467. struct batman_packet *batman_packet;
  468. struct hard_iface *hard_iface;
  469. int ret;
  470. hard_iface = container_of(ptype, struct hard_iface, batman_adv_ptype);
  471. skb = skb_share_check(skb, GFP_ATOMIC);
  472. /* skb was released by skb_share_check() */
  473. if (!skb)
  474. goto err_out;
  475. /* packet should hold at least type and version */
  476. if (unlikely(!pskb_may_pull(skb, 2)))
  477. goto err_free;
  478. /* expect a valid ethernet header here. */
  479. if (unlikely(skb->mac_len != sizeof(struct ethhdr)
  480. || !skb_mac_header(skb)))
  481. goto err_free;
  482. if (!hard_iface->soft_iface)
  483. goto err_free;
  484. bat_priv = netdev_priv(hard_iface->soft_iface);
  485. if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
  486. goto err_free;
  487. /* discard frames on not active interfaces */
  488. if (hard_iface->if_status != IF_ACTIVE)
  489. goto err_free;
  490. batman_packet = (struct batman_packet *)skb->data;
  491. if (batman_packet->version != COMPAT_VERSION) {
  492. bat_dbg(DBG_BATMAN, bat_priv,
  493. "Drop packet: incompatible batman version (%i)\n",
  494. batman_packet->version);
  495. goto err_free;
  496. }
  497. /* all receive handlers return whether they received or reused
  498. * the supplied skb. if not, we have to free the skb. */
  499. switch (batman_packet->packet_type) {
  500. /* batman originator packet */
  501. case BAT_PACKET:
  502. ret = recv_bat_packet(skb, hard_iface);
  503. break;
  504. /* batman icmp packet */
  505. case BAT_ICMP:
  506. ret = recv_icmp_packet(skb, hard_iface);
  507. break;
  508. /* unicast packet */
  509. case BAT_UNICAST:
  510. ret = recv_unicast_packet(skb, hard_iface);
  511. break;
  512. /* fragmented unicast packet */
  513. case BAT_UNICAST_FRAG:
  514. ret = recv_ucast_frag_packet(skb, hard_iface);
  515. break;
  516. /* broadcast packet */
  517. case BAT_BCAST:
  518. ret = recv_bcast_packet(skb, hard_iface);
  519. break;
  520. /* vis packet */
  521. case BAT_VIS:
  522. ret = recv_vis_packet(skb, hard_iface);
  523. break;
  524. default:
  525. ret = NET_RX_DROP;
  526. }
  527. if (ret == NET_RX_DROP)
  528. kfree_skb(skb);
  529. /* return NET_RX_SUCCESS in any case as we
  530. * most probably dropped the packet for
  531. * routing-logical reasons. */
  532. return NET_RX_SUCCESS;
  533. err_free:
  534. kfree_skb(skb);
  535. err_out:
  536. return NET_RX_DROP;
  537. }
  538. struct notifier_block hard_if_notifier = {
  539. .notifier_call = hard_if_event,
  540. };