• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/net/l2tp/

Lines Matching refs:tunnel

162 l2tp_session_id_hash(struct l2tp_tunnel *tunnel, u32 session_id)
164 return &tunnel->session_hlist[hash_32(session_id, L2TP_HASH_BITS)];
169 struct l2tp_session *l2tp_session_find(struct net *net, struct l2tp_tunnel *tunnel, u32 session_id)
177 * tunnel.
179 if (tunnel == NULL)
182 session_list = l2tp_session_id_hash(tunnel, session_id);
183 read_lock_bh(&tunnel->hlist_lock);
186 read_unlock_bh(&tunnel->hlist_lock);
190 read_unlock_bh(&tunnel->hlist_lock);
196 struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth)
203 read_lock_bh(&tunnel->hlist_lock);
205 hlist_for_each_entry(session, walk, &tunnel->session_hlist[hash], hlist) {
207 read_unlock_bh(&tunnel->hlist_lock);
213 read_unlock_bh(&tunnel->hlist_lock);
245 /* Lookup a tunnel by id
249 struct l2tp_tunnel *tunnel;
253 list_for_each_entry_rcu(tunnel, &pn->l2tp_tunnel_list, list) {
254 if (tunnel->tunnel_id == tunnel_id) {
256 return tunnel;
268 struct l2tp_tunnel *tunnel;
272 list_for_each_entry_rcu(tunnel, &pn->l2tp_tunnel_list, list) {
275 return tunnel;
321 struct l2tp_tunnel *tunnel = session->tunnel;
329 tunnel->stats.rx_packets++;
330 tunnel->stats.rx_bytes += length;
337 if (tunnel->version == L2TP_HDR_VER_2)
499 struct l2tp_tunnel *tunnel = session->tunnel;
514 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO,
516 tunnel->name, tunnel->tunnel_id, session->session_id);
532 if (tunnel->version == L2TP_HDR_VER_2) {
576 l2tp_session_set_header_len(session, tunnel->version);
600 l2tp_session_set_header_len(session, tunnel->version);
615 if (tunnel->version == L2TP_HDR_VER_2) {
702 int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
713 if (tunnel->sock && l2tp_verify_udp_checksum(tunnel->sock, skb))
721 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO,
722 "%s: recv short packet (len=%d)\n", tunnel->name, skb->len);
730 if (tunnel->debug & L2TP_MSG_DATA) {
735 printk(KERN_DEBUG "%s: recv: ", tunnel->name);
750 if (version != tunnel->version) {
751 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO,
753 tunnel->name, version, tunnel->version);
762 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_DEBUG,
763 "%s: recv control packet, len=%d\n", tunnel->name, length);
770 if (tunnel->version == L2TP_HDR_VER_2) {
775 /* Extract tunnel and session ID */
782 tunnel_id = tunnel->tunnel_id;
788 session = l2tp_session_find(tunnel->l2tp_net, tunnel, session_id);
791 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO,
793 tunnel->name, tunnel_id, session_id);
802 LIMIT_NETDEBUG("%s: UDP: bad checksum\n", tunnel->name);
803 UDP_INC_STATS_USER(tunnel->l2tp_net, UDP_MIB_INERRORS, 0);
804 tunnel->stats.rx_errors++;
825 struct l2tp_tunnel *tunnel;
827 tunnel = l2tp_sock_to_tunnel(sk);
828 if (tunnel == NULL)
831 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_DEBUG,
832 "%s: received %d bytes\n", tunnel->name, skb->len);
834 if (l2tp_udp_recv_core(tunnel, skb, tunnel->recv_payload_hook))
855 struct l2tp_tunnel *tunnel = session->tunnel;
859 u32 tunnel_id = tunnel->peer_tunnel_id;
883 struct l2tp_tunnel *tunnel = session->tunnel;
890 if (tunnel->encap == L2TP_ENCAPTYPE_UDP) {
927 struct l2tp_tunnel *tunnel = session->tunnel;
942 int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
962 tunnel->stats.tx_packets++;
963 tunnel->stats.tx_bytes += len;
967 tunnel->stats.tx_errors++;
982 /* For data skbs that we transmit, we associate with the tunnel socket
998 struct l2tp_tunnel *tunnel = session->tunnel;
999 struct sock *sk = tunnel->sock;
1006 int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
1032 /* Get routing info from the tunnel socket */
1036 switch (tunnel->encap) {
1089 * The tunnel context is deleted only when all session sockets have been
1094 struct l2tp_tunnel *tunnel;
1096 tunnel = sk->sk_user_data;
1097 if (tunnel == NULL)
1100 PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO,
1101 "%s: closing...\n", tunnel->name);
1104 l2tp_tunnel_closeall(tunnel);
1106 switch (tunnel->encap) {
1116 /* Remove hooks into tunnel socket */
1117 tunnel->sock = NULL;
1118 sk->sk_destruct = tunnel->old_sk_destruct;
1126 l2tp_tunnel_dec_refcount(tunnel);
1133 /* When the tunnel is closed, all the attached sessions need to go too.
1135 void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
1142 BUG_ON(tunnel == NULL);
1144 PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO,
1145 "%s: closing all sessions...\n", tunnel->name);
1147 write_lock_bh(&tunnel->hlist_lock);
1150 hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) {
1167 write_unlock_bh(&tunnel->hlist_lock);
1169 if (tunnel->version != L2TP_HDR_VER_2) {
1170 struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net);
1184 write_lock_bh(&tunnel->hlist_lock);
1194 write_unlock_bh(&tunnel->hlist_lock);
1198 /* Really kill the tunnel.
1199 * Come here only when all sessions have been cleared from the tunnel.
1201 void l2tp_tunnel_free(struct l2tp_tunnel *tunnel)
1203 struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net);
1205 BUG_ON(atomic_read(&tunnel->ref_count) != 0);
1206 BUG_ON(tunnel->sock != NULL);
1208 PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO,
1209 "%s: free...\n", tunnel->name);
1211 /* Remove from tunnel list */
1213 list_del_rcu(&tunnel->list);
1218 kfree(tunnel);
1222 /* Create a socket for the tunnel, if one isn't set up by
1300 struct l2tp_tunnel *tunnel = NULL;
1307 /* Get the tunnel socket from the fd, which was opened by
1351 tunnel = (struct l2tp_tunnel *)sk->sk_user_data;
1352 if (tunnel != NULL) {
1358 tunnel = kzalloc(sizeof(struct l2tp_tunnel), GFP_KERNEL);
1359 if (tunnel == NULL) {
1364 tunnel->version = version;
1365 tunnel->tunnel_id = tunnel_id;
1366 tunnel->peer_tunnel_id = peer_tunnel_id;
1367 tunnel->debug = L2TP_DEFAULT_DEBUG_FLAGS;
1369 tunnel->magic = L2TP_TUNNEL_MAGIC;
1370 sprintf(&tunnel->name[0], "tunl %u", tunnel_id);
1371 rwlock_init(&tunnel->hlist_lock);
1374 tunnel->l2tp_net = net;
1378 tunnel->debug = cfg->debug;
1381 tunnel->encap = encap;
1388 sk->sk_user_data = tunnel;
1390 /* Hook on the tunnel socket destructor so that we can cleanup
1391 * if the tunnel socket goes away.
1393 tunnel->old_sk_destruct = sk->sk_destruct;
1395 tunnel->sock = sk;
1398 /* Add tunnel to our list */
1399 INIT_LIST_HEAD(&tunnel->list);
1401 list_add_rcu(&tunnel->list, &pn->l2tp_tunnel_list);
1406 /* Bump the reference count. The tunnel context is deleted
1409 l2tp_tunnel_inc_refcount(tunnel);
1414 *tunnelp = tunnel;
1416 /* If tunnel's socket was created by the kernel, it doesn't
1428 int l2tp_tunnel_delete(struct l2tp_tunnel *tunnel)
1431 struct socket *sock = tunnel->sock ? tunnel->sock->sk_socket : NULL;
1433 /* Force the tunnel socket to close. This will eventually
1434 * cause the tunnel to be deleted via the normal socket close
1435 * mechanisms when userspace closes the tunnel socket.
1440 /* If the tunnel's socket was created by the kernel,
1456 struct l2tp_tunnel *tunnel;
1460 tunnel = session->tunnel;
1461 if (tunnel != NULL) {
1462 BUG_ON(tunnel->magic != L2TP_TUNNEL_MAGIC);
1465 write_lock_bh(&tunnel->hlist_lock);
1467 write_unlock_bh(&tunnel->hlist_lock);
1470 if (tunnel->version != L2TP_HDR_VER_2) {
1471 struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net);
1482 sock_put(tunnel->sock);
1484 /* This will delete the tunnel context if this
1485 * is the last session on the tunnel.
1487 session->tunnel = NULL;
1488 l2tp_tunnel_dec_refcount(tunnel);
1523 if (session->tunnel->encap == L2TP_ENCAPTYPE_UDP)
1530 struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunnel, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg)
1537 session->tunnel = tunnel;
1544 tunnel->tunnel_id, session->session_id);
1551 /* Inherit debug options from tunnel */
1552 session->debug = tunnel->debug;
1572 if (tunnel->version == L2TP_HDR_VER_2)
1577 l2tp_session_set_header_len(session, tunnel->version);
1583 l2tp_tunnel_inc_refcount(tunnel);
1585 /* Ensure tunnel socket isn't deleted */
1586 sock_hold(tunnel->sock);
1588 /* Add session to the tunnel's hash list */
1589 write_lock_bh(&tunnel->hlist_lock);
1591 l2tp_session_id_hash(tunnel, session_id));
1592 write_unlock_bh(&tunnel->hlist_lock);
1595 if (tunnel->version != L2TP_HDR_VER_2) {
1596 struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net);