Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
Pablo Neira Ayuso says: ==================== Netfilter/IPVS updates for net-next The following patchset contains Netfilter/IPVS updates for net-next: 1) Inspect the reply packets coming from DR/TUN and refresh connection state and timeout, from longguang yue and Julian Anastasov. 2) Series to add support for the inet ingress chain type in nf_tables. ==================== Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
a308283fdb
11 changed files with 281 additions and 75 deletions
|
|
@ -1081,6 +1081,12 @@ struct nft_table {
|
|||
u8 *udata;
|
||||
};
|
||||
|
||||
static inline bool nft_base_chain_netdev(int family, u32 hooknum)
|
||||
{
|
||||
return family == NFPROTO_NETDEV ||
|
||||
(family == NFPROTO_INET && hooknum == NF_INET_INGRESS);
|
||||
}
|
||||
|
||||
void nft_register_chain_type(const struct nft_chain_type *);
|
||||
void nft_unregister_chain_type(const struct nft_chain_type *);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,4 +53,37 @@ static inline void nft_set_pktinfo_ipv4_validate(struct nft_pktinfo *pkt,
|
|||
nft_set_pktinfo_unspec(pkt, skb);
|
||||
}
|
||||
|
||||
static inline int nft_set_pktinfo_ipv4_ingress(struct nft_pktinfo *pkt,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct iphdr *iph;
|
||||
u32 len, thoff;
|
||||
|
||||
if (!pskb_may_pull(skb, sizeof(*iph)))
|
||||
return -1;
|
||||
|
||||
iph = ip_hdr(skb);
|
||||
if (iph->ihl < 5 || iph->version != 4)
|
||||
goto inhdr_error;
|
||||
|
||||
len = ntohs(iph->tot_len);
|
||||
thoff = iph->ihl * 4;
|
||||
if (skb->len < len) {
|
||||
__IP_INC_STATS(nft_net(pkt), IPSTATS_MIB_INTRUNCATEDPKTS);
|
||||
return -1;
|
||||
} else if (len < thoff) {
|
||||
goto inhdr_error;
|
||||
}
|
||||
|
||||
pkt->tprot_set = true;
|
||||
pkt->tprot = iph->protocol;
|
||||
pkt->xt.thoff = thoff;
|
||||
pkt->xt.fragoff = ntohs(iph->frag_off) & IP_OFFSET;
|
||||
|
||||
return 0;
|
||||
|
||||
inhdr_error:
|
||||
__IP_INC_STATS(nft_net(pkt), IPSTATS_MIB_INHDRERRORS);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -70,4 +70,50 @@ static inline void nft_set_pktinfo_ipv6_validate(struct nft_pktinfo *pkt,
|
|||
nft_set_pktinfo_unspec(pkt, skb);
|
||||
}
|
||||
|
||||
static inline int nft_set_pktinfo_ipv6_ingress(struct nft_pktinfo *pkt,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
unsigned int flags = IP6_FH_F_AUTH;
|
||||
unsigned short frag_off;
|
||||
unsigned int thoff = 0;
|
||||
struct inet6_dev *idev;
|
||||
struct ipv6hdr *ip6h;
|
||||
int protohdr;
|
||||
u32 pkt_len;
|
||||
|
||||
if (!pskb_may_pull(skb, sizeof(*ip6h)))
|
||||
return -1;
|
||||
|
||||
ip6h = ipv6_hdr(skb);
|
||||
if (ip6h->version != 6)
|
||||
goto inhdr_error;
|
||||
|
||||
pkt_len = ntohs(ip6h->payload_len);
|
||||
if (pkt_len + sizeof(*ip6h) > skb->len) {
|
||||
idev = __in6_dev_get(nft_in(pkt));
|
||||
__IP6_INC_STATS(nft_net(pkt), idev, IPSTATS_MIB_INTRUNCATEDPKTS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, &flags);
|
||||
if (protohdr < 0)
|
||||
goto inhdr_error;
|
||||
|
||||
pkt->tprot_set = true;
|
||||
pkt->tprot = protohdr;
|
||||
pkt->xt.thoff = thoff;
|
||||
pkt->xt.fragoff = frag_off;
|
||||
|
||||
return 0;
|
||||
|
||||
inhdr_error:
|
||||
idev = __in6_dev_get(nft_in(pkt));
|
||||
__IP6_INC_STATS(nft_net(pkt), idev, IPSTATS_MIB_INHDRERRORS);
|
||||
return -1;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue