Skip to content
Snippets Groups Projects
sock.h 58.6 KiB
Newer Older
  • Learn to ignore specific revisions
  • 			   (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE)	| \
    			   (1UL << SOCK_TIMESTAMPING_SOFTWARE)		| \
    			   (1UL << SOCK_TIMESTAMPING_RAW_HARDWARE) 	| \
    			   (1UL << SOCK_TIMESTAMPING_SYS_HARDWARE))
    
    	if (sk->sk_flags & FLAGS_TS_OR_DROPS)
    		__sock_recv_ts_and_drops(msg, sk, skb);
    	else
    		sk->sk_stamp = skb->tstamp;
    }
    
    /**
     * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped
     * @sk:		socket sending this packet
    
     * @tx_flags:	filled with instructions for time stamping
    
     *
     * Currently only depends on SOCK_TIMESTAMPING* flags. Returns error code if
     * parameters are invalid.
     */
    
    extern int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags);
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    /**
     * sk_eat_skb - Release a skb if it is no longer needed
    
     * @sk: socket to eat this skb from
     * @skb: socket buffer to eat
    
     * @copied_early: flag indicating whether DMA operations copied this data early
    
    Linus Torvalds's avatar
    Linus Torvalds committed
     *
     * This routine must be called with interrupts disabled or with the socket
     * locked so that the sk_buff queue operation is ok.
    */
    
    #ifdef CONFIG_NET_DMA
    static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_early)
    {
    	__skb_unlink(skb, &sk->sk_receive_queue);
    	if (!copied_early)
    		__kfree_skb(skb);
    	else
    		__skb_queue_tail(&sk->sk_async_wait_queue, skb);
    }
    #else
    static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_early)
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    {
    	__skb_unlink(skb, &sk->sk_receive_queue);
    	__kfree_skb(skb);
    }
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    
    
    static inline
    struct net *sock_net(const struct sock *sk)
    {
    
    	return read_pnet(&sk->sk_net);
    
    void sock_net_set(struct sock *sk, struct net *net)
    
    	write_pnet(&sk->sk_net, net);
    
    /*
     * Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace.
    
    Lucas De Marchi's avatar
    Lucas De Marchi committed
     * They should not hold a reference to a namespace in order to allow
    
     * to stop it.
     * Sockets after sk_change_net should be released using sk_release_kernel
     */
    static inline void sk_change_net(struct sock *sk, struct net *net)
    {
    
    	sock_net_set(sk, hold_net(net));
    
    static inline struct sock *skb_steal_sock(struct sk_buff *skb)
    {
    	if (unlikely(skb->sk)) {
    		struct sock *sk = skb->sk;
    
    		skb->destructor = NULL;
    		skb->sk = NULL;
    		return sk;
    	}
    	return NULL;
    }
    
    
    extern void sock_enable_timestamp(struct sock *sk, int flag);
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    extern int sock_get_timestamp(struct sock *, struct timeval __user *);
    
    extern int sock_get_timestampns(struct sock *, struct timespec __user *);
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    
    /* 
     *	Enable debug/info messages 
     */
    
    extern int net_msg_warn;
    #define NETDEBUG(fmt, args...) \
    	do { if (net_msg_warn) printk(fmt,##args); } while (0)
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    
    
    #define LIMIT_NETDEBUG(fmt, args...) \
    	do { if (net_msg_warn && net_ratelimit()) printk(fmt,##args); } while(0)
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    
    extern __u32 sysctl_wmem_max;
    extern __u32 sysctl_rmem_max;
    
    
    extern void sk_init(void);
    
    
    extern __u32 sysctl_wmem_default;
    extern __u32 sysctl_rmem_default;
    
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    #endif	/* _SOCK_H */