inet: protect against too small mtu values.
[linux-block.git] / include / net / ip.h
index a2c61c36dc4afc2c2e334eeb2174f9e5636a106e..5b317c9f4470a93abae9cbe8e7dfd3e919aa8851 100644 (file)
@@ -339,10 +339,10 @@ static inline u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_o
 void inet_get_local_port_range(struct net *net, int *low, int *high);
 
 #ifdef CONFIG_SYSCTL
-static inline int inet_is_local_reserved_port(struct net *net, int port)
+static inline bool inet_is_local_reserved_port(struct net *net, unsigned short port)
 {
        if (!net->ipv4.sysctl_local_reserved_ports)
-               return 0;
+               return false;
        return test_bit(port, net->ipv4.sysctl_local_reserved_ports);
 }
 
@@ -351,20 +351,20 @@ static inline bool sysctl_dev_name_is_allowed(const char *name)
        return strcmp(name, "default") != 0  && strcmp(name, "all") != 0;
 }
 
-static inline int inet_prot_sock(struct net *net)
+static inline bool inet_port_requires_bind_service(struct net *net, unsigned short port)
 {
-       return net->ipv4.sysctl_ip_prot_sock;
+       return port < net->ipv4.sysctl_ip_prot_sock;
 }
 
 #else
-static inline int inet_is_local_reserved_port(struct net *net, int port)
+static inline bool inet_is_local_reserved_port(struct net *net, unsigned short port)
 {
-       return 0;
+       return false;
 }
 
-static inline int inet_prot_sock(struct net *net)
+static inline bool inet_port_requires_bind_service(struct net *net, unsigned short port)
 {
-       return PROT_SOCK;
+       return port < PROT_SOCK;
 }
 #endif
 
@@ -760,4 +760,9 @@ int ip_misc_proc_init(void);
 int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, u8 family,
                                struct netlink_ext_ack *extack);
 
+static inline bool inetdev_valid_mtu(unsigned int mtu)
+{
+       return likely(mtu >= IPV4_MIN_MTU);
+}
+
 #endif /* _IP_H */