35
35
* saddr is address of outgoing interface.
38
void ip_options_build(struct sk_buff * skb, struct ip_options * opt,
38
void ip_options_build(struct sk_buff *skb, struct ip_options *opt,
39
39
__be32 daddr, struct rtable *rt, int is_frag)
41
41
unsigned char *iph = skb_network_header(skb);
82
82
* NOTE: dopt cannot point to skb.
85
int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
85
int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb)
87
struct ip_options *sopt;
87
const struct ip_options *sopt;
88
88
unsigned char *sptr, *dptr;
89
89
int soffset, doffset;
502
static struct ip_options *ip_options_get_alloc(const int optlen)
500
static struct ip_options_rcu *ip_options_get_alloc(const int optlen)
504
return kzalloc(sizeof(struct ip_options) + ((optlen + 3) & ~3),
502
return kzalloc(sizeof(struct ip_options_rcu) + ((optlen + 3) & ~3),
508
static int ip_options_get_finish(struct net *net, struct ip_options **optp,
509
struct ip_options *opt, int optlen)
506
static int ip_options_get_finish(struct net *net, struct ip_options_rcu **optp,
507
struct ip_options_rcu *opt, int optlen)
511
509
while (optlen & 3)
512
opt->__data[optlen++] = IPOPT_END;
513
opt->optlen = optlen;
514
if (optlen && ip_options_compile(net, opt, NULL)) {
510
opt->opt.__data[optlen++] = IPOPT_END;
511
opt->opt.optlen = optlen;
512
if (optlen && ip_options_compile(net, &opt->opt, NULL)) {
523
int ip_options_get_from_user(struct net *net, struct ip_options **optp,
521
int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp,
524
522
unsigned char __user *data, int optlen)
526
struct ip_options *opt = ip_options_get_alloc(optlen);
524
struct ip_options_rcu *opt = ip_options_get_alloc(optlen);
530
if (optlen && copy_from_user(opt->__data, data, optlen)) {
528
if (optlen && copy_from_user(opt->opt.__data, data, optlen)) {
534
532
return ip_options_get_finish(net, optp, opt, optlen);
537
int ip_options_get(struct net *net, struct ip_options **optp,
535
int ip_options_get(struct net *net, struct ip_options_rcu **optp,
538
536
unsigned char *data, int optlen)
540
struct ip_options *opt = ip_options_get_alloc(optlen);
538
struct ip_options_rcu *opt = ip_options_get_alloc(optlen);
545
memcpy(opt->__data, data, optlen);
543
memcpy(opt->opt.__data, data, optlen);
546
544
return ip_options_get_finish(net, optp, opt, optlen);