--- zzzz-none-000/linux-4.9.279/net/ipv4/ip_sockglue.c 2021-08-08 06:38:54.000000000 +0000 +++ puma7-arm-6591-750/linux-4.9.279/net/ipv4/ip_sockglue.c 2023-02-08 10:58:16.000000000 +0000 @@ -14,6 +14,10 @@ * TOS tweaks. * Mike McLagan : Routing by source */ +/* +Includes Intel Corporation's changes/modifications dated: 2014-2019. +Changed/modified portions - Copyright © 2019, Intel Corporation. +*/ #include #include @@ -47,8 +51,32 @@ #include /* - * SOL_IP control messages. - */ +* TI Extension: +* +* Function: +* ip_cmsg_recv_ti_pktinfo(struct msghdr *msg, struct sk_buff *skb) +* +* Decsription: +* The function fills the ti_pktinfo structure for the +* sending relevant information to the user +*/ + +#ifdef CONFIG_TI_IP_PKTINFO_SOCKOPT +static void ip_cmsg_recv_ti_pktinfo(struct msghdr *msg, struct sk_buff *skb) +{ + struct ti_pktinfo info; + struct ethhdr *ehdr; +#ifdef CONFIG_TI_META_DATA + info.ifcpe_side = skb->ti_meta_info; +#endif + ehdr = eth_hdr(skb); + memcpy( info.mac_addr, ehdr->h_source, sizeof(info.mac_addr)); +#ifdef CONFIG_TI_META_DATA + skb->ti_meta_info=0; +#endif + put_cmsg(msg, SOL_IP, TI_IP_PKTINFO, sizeof(info), &info); +} +#endif static void ip_cmsg_recv_pktinfo(struct msghdr *msg, struct sk_buff *skb) { @@ -216,8 +244,23 @@ return; } - if (flags & IP_CMSG_CHECKSUM) + if (flags & IP_CMSG_CHECKSUM) { ip_cmsg_recv_checksum(msg, skb, tlen, offset); + + flags &= ~IP_CMSG_CHECKSUM; + if (!flags) + return; + } + +#ifdef CONFIG_TI_IP_PKTINFO_SOCKOPT + if (flags & TI_IP_CMSG_PKTINFO) { + ip_cmsg_recv_ti_pktinfo(msg, skb); + + flags &= ~TI_IP_CMSG_PKTINFO; + if (!flags) + return; + } +#endif } EXPORT_SYMBOL(ip_cmsg_recv_offset); @@ -298,7 +341,35 @@ ipc->tos = val; ipc->priority = rt_tos2priority(ipc->tos); break; +#ifdef CONFIG_TI_IP_PKTINFO_SOCKOPT + case TI_IP_PKTINFO: + { + printk("TI_IP_PKTINFO option is off\n"); + return -EINVAL; + } +#endif + +#ifdef CONFIG_TI_META_DATA + case TI_IP_META_DATA: + { + unsigned int* ptr_meta_info; + + /* Validate the length. */ + if (cmsg->cmsg_len != CMSG_LEN(sizeof(unsigned int))) + return -EINVAL; + /* Store the meta data into the cookie. */ + ptr_meta_info = (unsigned int *)CMSG_DATA(cmsg); + ipc->ti_meta_info = *ptr_meta_info; + + /* Print the Message on the console indicating that the kernel + * succesfully received the meta-data information from user-space. */ +#ifdef CONFIG_TI_META_DATA_CONSOLE_DUMP + printk ("Received Meta-Data:0x%x\n", ipc->ti_meta_info); +#endif /* CONFIG_TI_META_DATA_CONSOLE_DUMP */ + break; + } +#endif /* CONFIG_TI_META_DATA */ default: return -EINVAL; } @@ -613,6 +684,9 @@ case IP_MULTICAST_LOOP: case IP_RECVORIGDSTADDR: case IP_CHECKSUM: +#ifdef CONFIG_TI_IP_PKTINFO_SOCKOPT + case TI_IP_PKTINFO: +#endif if (optlen >= sizeof(int)) { if (get_user(val, (int __user *) optval)) return -EFAULT; @@ -676,6 +750,14 @@ else inet->cmsg_flags &= ~IP_CMSG_PKTINFO; break; +#ifdef CONFIG_TI_IP_PKTINFO_SOCKOPT + case TI_IP_PKTINFO: + if (val) + inet->cmsg_flags |= TI_IP_CMSG_PKTINFO; + else + inet->cmsg_flags &= ~TI_IP_CMSG_PKTINFO; + break; +#endif case IP_RECVTTL: if (val) inet->cmsg_flags |= IP_CMSG_TTL; @@ -1347,6 +1429,11 @@ case IP_PKTINFO: val = (inet->cmsg_flags & IP_CMSG_PKTINFO) != 0; break; +#ifdef CONFIG_TI_IP_PKTINFO_SOCKOPT + case TI_IP_PKTINFO: + val = (inet->cmsg_flags & TI_IP_CMSG_PKTINFO) != 0; + break; +#endif case IP_RECVTTL: val = (inet->cmsg_flags & IP_CMSG_TTL) != 0; break; @@ -1488,6 +1575,15 @@ info.ipi_ifindex = inet->mc_index; put_cmsg(&msg, SOL_IP, IP_PKTINFO, sizeof(info), &info); } +#ifdef CONFIG_TI_IP_PKTINFO_SOCKOPT + if (inet->cmsg_flags & TI_IP_CMSG_PKTINFO) { + /* struct ti_pktinfo info; + info.ifcpe_side = inet->mc_index; + put_cmsg(&msg, SOL_IP, TI_IP_PKTINFO, sizeof(info), &info); */ + printk("TI_IP_PKTINFO option is close in this mode\n"); + return -ENOPROTOOPT; + } +#endif if (inet->cmsg_flags & IP_CMSG_TTL) { int hlim = inet->mc_ttl; put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim);