ip_sockglue.c (bae6692c24236d0203f88a444986d86437a858fa) ip_sockglue.c (0b922b7a829c06e3b0790c58cd9ca026de86096e)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * The IP to API glue.
7 *
8 * Authors: see ip.c

--- 92 unchanged lines hidden (view full) ---

101 int offset)
102{
103 __wsum csum = skb->csum;
104
105 if (skb->ip_summed != CHECKSUM_COMPLETE)
106 return;
107
108 if (offset != 0)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * The IP to API glue.
7 *
8 * Authors: see ip.c

--- 92 unchanged lines hidden (view full) ---

101 int offset)
102{
103 __wsum csum = skb->csum;
104
105 if (skb->ip_summed != CHECKSUM_COMPLETE)
106 return;
107
108 if (offset != 0)
109 csum = csum_sub(csum, csum_partial(skb->data, offset, 0));
109 csum = csum_sub(csum, csum_partial(skb_transport_header(skb),
110 offset, 0));
110
111 put_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum);
112}
113
114static void ip_cmsg_recv_security(struct msghdr *msg, struct sk_buff *skb)
115{
116 char *secdata;
117 u32 seclen, secid;

--- 386 unchanged lines hidden (view full) ---

504 goto out;
505
506 copied = skb->len;
507 if (copied > len) {
508 msg->msg_flags |= MSG_TRUNC;
509 copied = len;
510 }
511 err = skb_copy_datagram_msg(skb, 0, msg, copied);
111
112 put_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum);
113}
114
115static void ip_cmsg_recv_security(struct msghdr *msg, struct sk_buff *skb)
116{
117 char *secdata;
118 u32 seclen, secid;

--- 386 unchanged lines hidden (view full) ---

505 goto out;
506
507 copied = skb->len;
508 if (copied > len) {
509 msg->msg_flags |= MSG_TRUNC;
510 copied = len;
511 }
512 err = skb_copy_datagram_msg(skb, 0, msg, copied);
512 if (err)
513 goto out_free_skb;
514
513 if (unlikely(err)) {
514 kfree_skb(skb);
515 return err;
516 }
515 sock_recv_timestamp(msg, sk, skb);
516
517 serr = SKB_EXT_ERR(skb);
518
519 if (sin && ipv4_datagram_support_addr(serr)) {
520 sin->sin_family = AF_INET;
521 sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) +
522 serr->addr_offset);

--- 15 unchanged lines hidden (view full) ---

538
539 put_cmsg(msg, SOL_IP, IP_RECVERR, sizeof(errhdr), &errhdr);
540
541 /* Now we could try to dump offended packet options */
542
543 msg->msg_flags |= MSG_ERRQUEUE;
544 err = copied;
545
517 sock_recv_timestamp(msg, sk, skb);
518
519 serr = SKB_EXT_ERR(skb);
520
521 if (sin && ipv4_datagram_support_addr(serr)) {
522 sin->sin_family = AF_INET;
523 sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) +
524 serr->addr_offset);

--- 15 unchanged lines hidden (view full) ---

540
541 put_cmsg(msg, SOL_IP, IP_RECVERR, sizeof(errhdr), &errhdr);
542
543 /* Now we could try to dump offended packet options */
544
545 msg->msg_flags |= MSG_ERRQUEUE;
546 err = copied;
547
546out_free_skb:
547 kfree_skb(skb);
548 consume_skb(skb);
548out:
549 return err;
550}
551
552
553/*
554 * Socket option code for IP. This is the end of the line after any
555 * TCP,UDP etc options on an IP socket.

--- 631 unchanged lines hidden (view full) ---

1187 */
1188void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
1189{
1190 struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb);
1191 bool prepare = (inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) ||
1192 ipv6_sk_rxinfo(sk);
1193
1194 if (prepare && skb_rtable(skb)) {
549out:
550 return err;
551}
552
553
554/*
555 * Socket option code for IP. This is the end of the line after any
556 * TCP,UDP etc options on an IP socket.

--- 631 unchanged lines hidden (view full) ---

1188 */
1189void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
1190{
1191 struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb);
1192 bool prepare = (inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) ||
1193 ipv6_sk_rxinfo(sk);
1194
1195 if (prepare && skb_rtable(skb)) {
1195 pktinfo->ipi_ifindex = inet_iif(skb);
1196 /* skb->cb is overloaded: prior to this point it is IP{6}CB
1197 * which has interface index (iif) as the first member of the
1198 * underlying inet{6}_skb_parm struct. This code then overlays
1199 * PKTINFO_SKB_CB and in_pktinfo also has iif as the first
1200 * element so the iif is picked up from the prior IPCB
1201 */
1196 pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);
1197 } else {
1198 pktinfo->ipi_ifindex = 0;
1199 pktinfo->ipi_spec_dst.s_addr = 0;
1200 }
1201 skb_dst_drop(skb);
1202}
1203

--- 376 unchanged lines hidden ---
1202 pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);
1203 } else {
1204 pktinfo->ipi_ifindex = 0;
1205 pktinfo->ipi_spec_dst.s_addr = 0;
1206 }
1207 skb_dst_drop(skb);
1208}
1209

--- 376 unchanged lines hidden ---